Last active
August 29, 2015 14:04
-
-
Save stevejenkins/3f5ea94ba603c9a28412 to your computer and use it in GitHub Desktop.
AlarmServer for SmartThings Init Script
This file contains 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 | |
# chkconfig: 23456 90 10 | |
# description: AlarmServer | |
# Middleware between SmartThings and EnvisaLink | |
# processname: alarmserver.py | |
# v1.1 | |
# by Steve Jenkins (steve@stevejenkins.com) | |
workdir=/usr/local/bin/AlarmServer | |
start() { | |
cd $workdir | |
/usr/bin/python26 $workdir/alarmserver.py & | |
echo "AlarmServer started." | |
} | |
stop() { | |
pid=`pgrep -f '/alarmserver.py$'` | |
echo $pid | |
kill $pid | |
sleep 2 | |
echo "AlarmServer stopped." | |
} | |
status() { | |
if pgrep -f "alarmserver.py"; then | |
echo "AlarmServer is running." | |
else | |
echo "AlarmServer is not running." | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: /etc/init.d/alarmserver {start|stop|restart}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment