4 TEMPLATES_DIR=/usr/share/monit-cn
10 if [ ! -r "$filename" ]; then
15 script='BEGIN { RS = "[ \t\n]+" }
18 if (line[j] == "pidfile")
20 pidfiles=$(awk "$script" < "$filename" | sed -e 's/"//g')
21 check_pidfile $pidfiles
31 if [ $RET -eq 1 ]; then
48 if ! kill -0 "$1" >/dev/null 2>&1; then
58 #####################################################################
61 if [ ! -d "$MONIT_DIR" ]; then
65 for i in $(find "$MONIT_DIR" -name '*.conf'); do
67 if [ ! $RET -eq 0 ]; then
68 serviceconf=$(basename $i)
69 echo "CN: Disabled $serviceconf"
75 for i in $(find "$TEMPLATES_DIR" -name '*.conf'); do
76 serviceconf=$(basename $i)
77 if [ -r "$MONIT_DIR"/$serviceconf.disabled ]; then
78 check_service "$MONIT_DIR"/$serviceconf.disabled
79 if [ $RET -eq 0 ]; then
80 if [ ! -r "$MONIT_DIR"/$serviceconf ]; then
81 echo "CN: Enabled $serviceconf (previously disabled)"
82 mv "$MONIT_DIR"/$serviceconf.disabled \
83 "$MONIT_DIR"/$serviceconf
89 if [ $RET -eq 0 ]; then
90 if [ ! -r "$MONIT_DIR"/$serviceconf ]; then
91 echo "CN: Enabled $serviceconf (new service)"
99 if [ $changed -eq 1 ]; then
100 echo "CN: Stopping/restarting monit service"
101 pkill -9 -f /usr/sbin/monit || true
103 echo "CN: No new services detected, sorry"