Skip to content

Instantly share code, notes, and snippets.

@annesteenbeek
Created April 11, 2017 23:42
Show Gist options
  • Save annesteenbeek/dc4dd8d07e7a61e0832711d65215245e to your computer and use it in GitHub Desktop.
Save annesteenbeek/dc4dd8d07e7a61e0832711d65215245e to your computer and use it in GitHub Desktop.
Cloudprint init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: cloudprint
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Manage cloudprint deamon.
### END INIT INFO
RUNAS=anne
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/cloudprint
NAME=cloudprint
PIDFILE=/var/run/$NAME.pid
DESC="Cloudprint daemon."
SCRIPTNAME=/etc/init.d/cloudprint
DAEMON_OPTS="-d"
# Exit if cloudprint is not installed
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
start() {
log_daemon_msg "Starting $DESC" "$NAME"
mkdir -p `dirname "$PIDFILE"`
start-stop-daemon --start --oknodo --user "$RUNAS" --chuid "$RUNAS" --pidfile "$PIDFILE" --exec $DAEMON -- "$DAEMON_OPTS"
status=$?
log_end_msg $status
}
status() {
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
}
stop() {
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME --remove-pidfile
status=$?
log_end_msg $status
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment