-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrol_script
68 lines (62 loc) · 1.11 KB
/
control_script
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: ptokax
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop/restart the services for PtokaX DC Hub.
### END INIT INFO
PXUSER=root
PXPATH=/etc/ptokax
PXBIN=/usr/bin/ptokax
px_start() {
if [ -x $PXBIN ]; then
if [ "$(pidof $PXBIN)" != "" ]; then
echo "PtokaX already running!"
else
ulimit -n 29240
su -p -c "$PXBIN -d -c $PXPATH" $PXUSER
fi
fi
}
px_stop() {
if [ "$(pidof $PXBIN)" != "" ]; then
kill -15 $(pidof $PXBIN)
echo "PtokaX stopping..."
else
echo "PtokaX not running!"
fi
}
px_restart() {
px_stop
while [ "$(pidof $PXBIN)" != "" ]; do
sleep 1
done
px_start
}
px_status() {
if [ "$(pidof $PXBIN)" != "" ]; then
echo "PtokaX running with PID(s): $(pidof $PXBIN)"
else
echo "PtokaX not running!"
fi
}
case "$1" in
'start')
px_start
;;
'stop')
px_stop
;;
'restart')
px_restart
;;
'status')
px_status
;;
*)
echo "Usage start|stop|restart|status"
esac
exit 0