-
Notifications
You must be signed in to change notification settings - Fork 0
/
x.startup
executable file
·81 lines (73 loc) · 1.55 KB
/
x.startup
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
#
# x.startup - This shell script takes care of starting and stopping monitad
#
# Author: rockmetoo
# Email: rockmetoo@gmail.com
red='\e[0;31m'
green='\e[0;32m'
yellow='\e[0;33m'
blue='\e[0;34m'
NC='\e[0m'
PIDFILE=/var/run/monitad.pid
DAEMON=/home/monitad/monitad
processCheck() {
ps -p $1 > /dev/null
if [ $? -eq 0 ]
then
echo -e "$2 ${green}running${NC} [$1]"
else
echo -e "$2 ${yellow}not found (down?)${NC}"
fi
}
start() {
echo -n "Starting monitad Daemon Server..."
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
echo monitad already running: $PID
exit 2;
else
$DAEMON
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && mkdir -p /var/log/monitad && mkdir -p /var/lock/monitad/ && touch /var/lock/monitad/monitad
return $RETVAL
fi
}
stop() {
echo -n "Shutting down monitad..."
echo
killall -9 monitad
echo
rm -f /var/lock/monitad/monitad
rm -f /var/run/monitad.pid
return 0
}
status() {
if [ -f $PIDFILE ]
then
processCheck `cat $PIDFILE` "monitad"
else
echo -e "monitad ${blue}not running${NC}"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: {start|stop|restart|status}"
exit 1
;;
esac
exit $?