-
-
Save elvisimprsntr/5274928 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# This starts and stops SiriProxy | |
# | |
### BEGIN INIT INFO | |
# Provides: siriproxy | |
# Required-Start: $all | |
# Required-Stop: | |
# Short-Description: SiriProxy | |
# Description: SiriProxy Server | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
### END INIT INFO | |
# Source function library. | |
. /lib/lsb/init-functions | |
# Set RVM path - assumes SiriProxy installed as root. | |
[ -s "/etc/profile.d/rvm.sh" ] && . "/etc/profile.d/rvm.sh" | |
# Use the next line if SiriProxy is installed as a user - I think the syntax is correct. | |
#[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm" | |
DESC="SiriProxy Server" | |
NAME=siriproxy | |
DAEMON=`/usr/bin/which siriproxy` | |
PIDFILE=/var/run/$NAME.pid | |
# Use the next line to add SiriProxy options or add the options to the config.yml file, but not both. | |
DAEMON_ARGS="server" | |
LOG=/var/log/$NAME.log | |
[ -x $binary ] || exit 0 | |
RETVAL=0 | |
start() { | |
echo -n "[....]Starting SiriProxy: " | |
rm -f $LOG | |
# You may need to change the --chuid option if SiriProxy is installed as a user | |
start-stop-daemon --start --quiet --chuid root:root --pidfile "$PIDFILE" --make-pidfile \ | |
--exec "$DAEMON" -b --oknodo -- $DAEMON_ARGS | |
log_end_msg $? | |
} | |
stop() { | |
echo -n "[....]Shutting down SiriProxy: " | |
# You may need to change the --chuid option if SiriProxy is installed as a user | |
start-stop-daemon --stop --quiet --chuid root:root --pidfile "$PIDFILE" \ | |
--retry 1 --oknodo | |
log_end_msg $? | |
} | |
restart() { | |
stop | |
sleep 1 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
;; | |
esac | |
exit 0 | |
#!/bin/bash | |
# | |
# This starts and stops SiriProxy | |
# | |
### BEGIN INIT INFO | |
# Provides: siriproxy | |
# Required-Start: $all | |
# Required-Stop: | |
# Short-Description: SiriProxy | |
# Description: SiriProxy Server | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
### END INIT INFO | |
# Source function library. | |
. /lib/lsb/init-functions | |
# Set RVM path - assumes SiriProxy installed as root. | |
[ -s "/etc/profile.d/rvm.sh" ] && . "/etc/profile.d/rvm.sh" | |
# Use the next line if SiriProxy is installed as a user - I think the syntax is correct. | |
#[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm" | |
DESC="SiriProxy Server" | |
NAME=siriproxy | |
DAEMON=`/usr/bin/which siriproxy` | |
PIDFILE=/var/run/$NAME.pid | |
# Use the next line to add SiriProxy options or add the options to the config.yml file, but not both. | |
DAEMON_ARGS="server" | |
LOG=/var/log/$NAME.log | |
[ -x $binary ] || exit 0 | |
RETVAL=0 | |
start() { | |
echo -n "[....]Starting SiriProxy: " | |
rm -f $LOG | |
# You may need to change the --chuid option if SiriProxy is installed as a user | |
start-stop-daemon --start --quiet --chuid root:root --pidfile "$PIDFILE" \ | |
--exec "$DAEMON" --oknodo -- $DAEMON_ARGS >> $LOG 2>&1 | |
log_end_msg $? | |
} | |
stop() { | |
echo -n "[....]Shutting down SiriProxy: " | |
# You may need to change the --chuid option if SiriProxy is installed as a user | |
start-stop-daemon --stop --quiet --chuid root:root --pidfile "$PIDFILE" \ | |
--retry 1 --oknodo | |
log_end_msg $? | |
} | |
restart() { | |
stop | |
sleep 1 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
;; | |
esac | |
exit 0 |
Have you tried adding --make-pidfile to your start up? I believe that will create the siriproxy.pid. Once the pid file is created, it seems to successfully stop.
Correct @dblanken, I've tested it and now the daemon successfully stop. Thanks
Where do you add the --make-pidfile
?
At startup siriproxylog hangs here:
[....]Starting SiriProxy:
When I stop it, it says it stopped.
/etc/init.d/siriproxylog stop
[....]Shutting down SiriProxy: ...done.
But when I start it, it says it fails (it never stopped running)
/etc/init.d/siriproxylog start
[....]Starting SiriProxy: ...fail!
updated script to include --make-pidfile. thanks @dblanken
Note: per the start-stop-daemon man page --make-pidfile only works with the background option, thus the stop daemon method will not work with the siriproxylog version
Curious whether you've done further elaboration on this siriproxy to accomplish other IoT tasks.
Note: The stop method does not actually stop the daemon. I have to figure that one out some other time.