Skip to content

Commit

Permalink
Better command line interface
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed Jul 13, 2015
1 parent 75992ef commit a65ad50
Show file tree
Hide file tree
Showing 7 changed files with 388 additions and 220 deletions.
10 changes: 8 additions & 2 deletions scripts/octoprint.default
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
# The init.d script will only run if this variable non-empty.
OCTOPRINT_USER=pi

# base directory to use
#BASEDIR=/home/pi/.octoprint

# configuration file to use
#CONFIGFILE=/home/pi/.octoprint/config.yaml

# On what port to run daemon, default is 5000
PORT=5000

# Path to the OctoPrint executable, use this to override the default setting "/usr/bin/octoprint"
#DAEMON=/path/to/octoprint/executable
# Path to the OctoPrint executable, you need to set this to match your installation!
#DAEMON=/home/pi/OctoPrint/venv/bin/octoprint

# What arguments to pass to octoprint, usually no need to touch this
DAEMON_ARGS="--port=$PORT"
Expand Down
29 changes: 23 additions & 6 deletions scripts/octoprint.init
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
# Author: Sami Olmari

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Octoprint Daemon"
NAME="Octoprint"
DAEMON=/usr/local/bin/octoprint
PIDFILE=/var/run/$NAME.pid
DESC="OctoPrint Daemon"
NAME="OctoPrint"
PKGNAME=octoprint
PIDFILE=/var/run/$PKGNAME.pid
SCRIPTNAME=/etc/init.d/$PKGNAME

# Read configuration variable file if it is present
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME

# Exit if the octoprint is not installed
# Exit if the DAEMON is not set
if [ -z "$DAEMON" ]
then
log_warning_msg "Not starting $PKGNAME, DAEMON not set in /etc/default/$PKGNAME."
exit 0
fi

# Exit if the DAEMON is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
Expand All @@ -48,6 +54,17 @@ then
exit 0
fi

COMMAND_ARGS=
if [ -z "$BASEDIR" ]
then
COMMAND_ARGS="--basedir $BASEDIR $COMMAND_ARGS"
fi

if [ -z "$CONFIGFILE" ]
then
COMMAND_ARGS="--config $CONFIGFILE $COMMAND_ARGS"
fi

#
# Function to verify if a pid is alive
#
Expand All @@ -74,7 +91,7 @@ do_start()
if [ $RETVAL != 0 ]; then
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \
--exec $DAEMON --chuid $OCTOPRINT_USER --user $OCTOPRINT_USER --umask $UMASK --nicelevel=$NICELEVEL \
-- $DAEMON_ARGS
-- $COMMAND_ARGS serve $DAEMON_ARGS
RETVAL="$?"
fi
}
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"rsa",
"pkginfo",
"requests",
"semantic_version"
"semantic_version",
"Click"
]

# Additional requirements for optional install options
Expand Down
Loading

0 comments on commit a65ad50

Please sign in to comment.