Last active
August 29, 2015 14:00
-
-
Save rmamba/1bfd4e180df1b323211c to your computer and use it in GitHub Desktop.
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 | |
# Generic Daemon start/stop script | |
# This goes to /etc/init.d folder | |
# $: /etc/init.d/btsyncd | |
# Replace: | |
# {PROGRAM} with program name [btsync] | |
# {EXEPATH} with path to program [/home/pi] | |
# {PIDFILE} with PID file name [/var/run/btsync.pid] | |
# {PARAMETERS} add parameters to command line [> /var/log/btsync.log 2>&1] | |
# or leave parameters empty if not needed | |
# And you're good to go | |
PROGRAM={PROGRAM} | |
EXEPATH={EXEPATH} | |
PIDFILE={PIDFILE} | |
do_start () { | |
$EXEPATH/$PROGRAM {PARAMETERS} | |
# echo $! > $PIDFILE | |
} | |
do_status () { | |
echo "Process ID at: " | |
cat $PIDFILE | |
echo | |
} | |
do_stop () { | |
kill -9 `cat $PIDFILE` | |
rm $PIDFILE | |
} | |
case "$1" in | |
start|"") | |
do_start | |
;; | |
restart|reload|force-reload) | |
do_stop | |
sleep 4 | |
do_start | |
;; | |
stop) | |
do_stop | |
;; | |
status) | |
do_status | |
exit $? | |
;; | |
*) | |
echo "Usage: $PROGRAM [start|stop|status]" >&2 | |
exit 3 | |
;; | |
esac | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment