-
Notifications
You must be signed in to change notification settings - Fork 1
/
pywws-livelog
executable file
·61 lines (55 loc) · 1.18 KB
/
pywws-livelog
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: pywws-livelog-daemon
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start pywws daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
DAEMON=/usr/local/bin/pywws-livelog-daemon.py
PIDFILE=/var/run/pywws.pid
DATADIR=/home/pi/weather/data
LOGFILE=$DATADIR/live_logger.log
RUNASUSER=pi
UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
case $1 in
start)
log_daemon_msg "Starting pywws service" "pywws"
if [ -z "$UGID" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
fi
$DAEMON -v $DATADIR $LOGFILE start
status=$?
log_end_msg $status
;;
stop)
log_daemon_msg "Stopping pywws service" "pywws"
$DAEMON -v $DATADIR $LOGFILE stop
log_end_msg $?
rm -f $PIDFILE
;;
restart|force-reload)
$DAEMON -v $DATADIR $LOGFILE restart
;;
try-restart)
if $0 status >/dev/null; then
$0 restart
else
exit 0
fi
;;
reload)
exit 3
;;
status)
status_of_proc $DAEMON "pywws service"
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
exit 2
;;
esac