forked from mdavidsaver/ioclogserv2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ioclogserver.init
executable file
·101 lines (86 loc) · 2 KB
/
ioclogserver.init
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#! /bin/sh
#
### BEGIN INIT INFO
# Provides: ioclogserver2
# Required-Start: $remote_fs $local_fs $network $syslog $time
# Required-Stop: $remote_fs $local_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Log recorder daemon for EPICS IOCS
# Description: Receives log messages from IOCS and writes them to file
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/twistd
DNAME=twistd
NAME=ioclogserver2
DESC="Log recorder daemon for EPICS IOCS"
# defaults
RUN=no
RUN_AS_USER=ioclogserver
RUN_AS_GROUP=nogroup
CONF_FILE="/etc/ioclogserver.conf"
PID_FILE="/var/run/$NAME.pid"
# Include admin settings if available
if [ -f /etc/default/ioclogserver2 ] ; then
. /etc/default/ioclogserver2
fi
DAEMON_OPTS="--logfile=/var/log/epics/daemon.log --pidfile=$PID_FILE --uid=$RUN_AS_USER --gid=$RUN_AS_GROUP --umask=0022"
DAEMON_OPTS="$DAEMON_OPTS ioclogserver -C $CONF_FILE -M 2223"
SSD_OPTS="-q --pidfile $PID_FILE"
SSD_OPTS="$SSD_OPTS --user $RUN_AS_USER --name $DNAME"
SSD_OPTS="$SSD_OPTS --startas $DAEMON"
export PYTHONPATH=/usr/local/ioclogserv
set -e
. /lib/lsb/init-functions
serv_start() {
start-stop-daemon --start $SSD_OPTS -- $DAEMON_OPTS
}
serv_stop() {
start-stop-daemon --stop $SSD_OPTS
}
serv_status() {
#Debian >= 7...
#start-stop-daemon --status $SSD_OPTS
#Debian <= 6 (and others)
status_of_proc -p "$PID_FILE" "" "$NAME"
}
serv_restart() {
serv_stop && sleep 1 && serv_start
}
case "$1" in
start)
echo -n "Starting $DESC: "
serv_start
RET=$?
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
serv_stop
RET=$?
echo "$NAME."
;;
force-reload)
# check whether $DAEMON is running. If so, restart
echo -n "Reloading $DESC: "
serv_status && serv_restart
RET=$?
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
serv_restart
RET=$?
echo "$NAME."
;;
status)
serv_status
RET=$?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit ${RET:=42}