From 06cbe6081f84ac4c331abc20dffcdf9d02c33eba Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 24 Mar 2013 13:16:17 +0100 Subject: [PATCH] added init script --- octoprint.init | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 octoprint.init diff --git a/octoprint.init b/octoprint.init new file mode 100755 index 0000000..ad0a983 --- /dev/null +++ b/octoprint.init @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Copy this script to /etc/init.d/octoprint and adjust the variables +# at the top to match your installation (should be okay for a Raspian +# setup). Then link it to the correct run levels. On Debian/Rasbian +# just call 'sudo update-rc.d octoprint defaults' + +### BEGIN INIT INFO +# Provides: octoprint +# Required-Start: $local_fs networking +# Required-Stop: +# Should-Start: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Run octoprint +# Description: Octoprint provides a responsive web interface for +# controlling a 3D printer +### END INIT INFO + + +# OctoPrint's run script +DAEMON=/home/pi/OctoPrint/run + +# Port to use +PORT=5000 + +# Run as this user +RUNAS=pi + +# Exit if the run script is not found +[ -x "$DAEMON" ] || exit 0 + + +case "$1" in + start) + su $RUNAS -c "$DAEMON --port=$PORT --daemon start" + ;; + stop) + su $RUNAS -c "$DAEMON --port=$PORT --daemon stop" + ;; + restart) + su $RUNAS -c "$DAEMON --port=$PORT --daemon restart" + ;; + *) + echo "Usage: $0 {start|stop|restart}" >&2 + ;; +esac + +: