From f850aa8523df1a916ed910f92c5465703260b0e2 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Thu, 22 Nov 2018 01:46:56 +0000 Subject: [PATCH] Added init script. --- init.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 init.sh diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..be3bfef --- /dev/null +++ b/init.sh @@ -0,0 +1,61 @@ +#! /bin/bash +### BEGIN INIT INFO +# Provides: robotd +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Robot control daemon. +### END INIT INFO + +start() { + PID=`pidof robotd` + if [ $? -eq 0 ] + then + echo "robotd already started." + return + else + echo "Starting robotd" + robotd + echo "Done." + fi +} + +stop() { + PID=`pidof weblabsd` + if [ $? -eq 0 ] + then + echo "Stopping robotd" + kill -s INT `pidof robotd` + echo "Done." + else + echo "robotd already stopped." + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + PID=`pidof robotd` + if [ $? -eq 0 ] + then + echo "robotd is running." + else + echo "robotd is down." + fi + ;; + restart) + stop + start + ;; + *) + echo "Usage: {start|stop|restart|status}" + exit 1 + ;; +esac +exit $?