-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaemon
More file actions
executable file
·59 lines (48 loc) · 1.42 KB
/
daemon
File metadata and controls
executable file
·59 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#-----------
# Configurations
#-----------
DAEMON_NAME=${DAEMON_NAME-ping}
DAEMON_LOG=${DAEMON_LOG-/var/log/$DAEMON_NAME.log}
DAEMON_PID=${DAEMON_PID-/var/log/$DAEMON_NAME.pid}
DAEMON_COMMAND=${DAEMON_COMMAND-ping localhost}
DAEMON_SCRIPT=${DAEMON_SCRIPT-/usr/local/$DAEMON_NAME.d}
DAEMON_STOP_SCRIPT=${DAEMON_STOP_SCRIPT-${DAEMON_SCRIPT}_stop}
MONIT_CONF_DIR=${MONIT_CONF_DIR-/etc/monit/conf.d}
MONIT_TIMEOUT=${MONIT_TIMEOUT-30}
MONIT_USER=${MONIT_USER-root}
MONIT_HOME=${MONIT_HOME-/root}
#-----------
# Install Script
#-----------
if [[ ! -e $MONIT_CONF_DIR ]]; then
mkdir -p $MONIT_CONF_DIR
chown $MONIT_USER $MONIT_CONF_DIR
echo " -- Created $MONIT_CONF_DIR"
fi
printf "%b" "#!/bin/bash
logfile=$DAEMON_LOG
nohup $DAEMON_COMMAND > \$logfile &
pid=\$!
echo \"Detached $DAEMON_NAME on pid \$pid (watch it by running the following script)\"
echo \"tail -f \$logfile\"
echo \$pid > $DAEMON_PID
" > $DAEMON_SCRIPT
printf "%b" "
#!/bin/
kill -9 \`cat $DAEMON_PID\`
echo "" > $DAEMON_PID
" > $DAEMON_STOP_SCRIPT
chmod 755 $DAEMON_SCRIPT
chmod 755 $DAEMON_STOP_SCRIPT
echo " -- Created $DAEMON_SCRIPT"
echo " -- Created $DAEMON_STOP_SCRIPT"
MONIT_NAME=$DAEMON_NAME \
MONIT_PID=$DAEMON_PID \
MONIT_START=$DAEMON_SCRIPT \
MONIT_STOP=$DAEMON_STOP_SCRIPT \
MONIT_TIMEOUT=$MONIT_TIMEOUT \
MONIT_CFG_FILE=$MONIT_CONF_DIR/$DAEMON_NAME.cnf \
MONIT_USER=$MONIT_USER \
MONIT_HOME=$MONIT_HOME \
./bits/monit/checkpid