-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharcom.rc
executable file
·66 lines (61 loc) · 1.53 KB
/
arcom.rc
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: arcom
# Required-Start: $network $syslog udev
# Required-Stop: $network $syslog udev
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Start ARCOM daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
RUNASUSER=arcom
RUNDIR=$(getent passwd $RUNASUSER | cut -f 6 -d:) || true
DAEMON="$RUNDIR/arcom-server.py"
PIDFILE="$RUNDIR/arcom.pid"
ARCOM_OPTS="--pidfile=$PIDFILE"
case $1 in
start)
log_daemon_msg "Starting ARCOM server" "arcom-server"
if [ -z "$RUNDIR" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
elif [ ! -d "$RUNDIR" ]; then
log_failure_msg "home directory \"$RUNDIR\" does not exist"
exit 1
elif [ ! -x "$DAEMON" ]; then
log_failure_msg "\"$DAEMON\" is not present or executable"
exit 1
fi
start-stop-daemon --start --background --verbose --oknodo --pidfile $PIDFILE \
--no-close --chdir $RUNDIR --chuid $RUNASUSER --startas $DAEMON -- $ARCOM_OPTS
status=$?
log_end_msg $status
;;
stop)
log_daemon_msg "Stopping ARCOM server" "arcom-server"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
log_end_msg $?
rm -f $PIDFILE
;;
restart|force-reload)
$0 stop && sleep 2 && $0 start
;;
try-restart)
if $0 status >/dev/null; then
$0 restart
else
exit 0
fi
;;
reload)
exit 3
;;
status)
status_of_proc $DAEMON "ARCOM server"
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
exit 2
;;
esac