From 07222fd8b1de8243bde54396298ad064b1502c91 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 20 Mar 2015 03:38:20 +0000 Subject: [PATCH] add init script --- init.d-walnut | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 init.d-walnut diff --git a/init.d-walnut b/init.d-walnut new file mode 100755 index 0000000..009252a --- /dev/null +++ b/init.d-walnut @@ -0,0 +1,39 @@ +### BEGIN INIT INFO +# Provides: walnut +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: WALNUT Home Cloud +### END INIT INFO + +export PATH=$PATH:/bin:/usr/bin:/usr/local/bin + +PIDFILE=/var/run/walnut.pid +DATE=`date '+%F_%H-%M-%S'` + +cd /srv/walnut + +case "$1" in + start) + mkdir -p /srv/walnut/logs + mkdir -p /srv/walnut/.forever + exec forever -p /srv/walnut/.forever --minUptime=20000 --spinSleepTime=100 --workingDir=/srv/walnut/ -l "/srv/walnut/logs/access.${DATE}.log" -e "/srv/walnut/logs/error.${DATE}.log" --pidFile=$PIDFILE start /srv/walnut/bin/walnut.js + ;; + stop) + exec forever stopall + ;; + restart) + mkdir -p /srv/walnut/logs + mkdir -p /srv/walnut/.forever + exec forever stopall + exec forever -p /srv/walnut/.forever --minUptime=20000 --spinSleepTime=100 --workingDir=/srv/walnut/ -l "/srv/walnut/logs/access.${DATE}.log" -e "/srv/walnut/logs/error.${DATE}.log" --pidFile=$PIDFILE start /srv/walnut/bin/walnut.js + ;; + *) + + echo "Usage: /etc/init.d/walnut {start|stop}" + exit 1 + ;; +esac + +exit 0