Created
July 17, 2015 14:13
-
-
Save wingrunr21/86983c18c2e6f29744df to your computer and use it in GitHub Desktop.
HoneyAlarmServer Raspberry Pi init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# /etc/init.d/honeyalarmserver | |
### BEGIN INIT INFO | |
# Provides: honeyalarmserver | |
# Required-Start: $local_fs $network | |
# Required-Stop: $local_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Honey Alarm Server service | |
# Description: Honey Alarm Server service | |
### END INIT INFO | |
workdir=/path/to/HoneyAlarmServer | |
start() { | |
cd $workdir | |
/usr/bin/python $workdir/alarmserver.py -c $workdir/alarmserver.cfg & | |
echo "HoneyAlarmServer started." | |
} | |
stop() { | |
pid=`pgrep -f alarmserver.py` | |
kill -15 $pid | |
sleep 2 | |
echo "HoneyAlarmServer stopped." | |
} | |
status() { | |
if pgrep -f alarmserver.py; then | |
echo "HoneyAlarmServer is running." | |
else | |
echo "HoneyAlarmServer is not running." | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: /etc/init.d/honeyalarmserver {start|stop|restart|status}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment