Skip to content

Instantly share code, notes, and snippets.

@socram8888
Created January 3, 2021 16:58
Show Gist options
  • Save socram8888/3087ac96615580556c554397cfc7c095 to your computer and use it in GitHub Desktop.
Save socram8888/3087ac96615580556c554397cfc7c095 to your computer and use it in GitHub Desktop.
Stubby sysvinit init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: stubby
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: stubby service
# Description: stubby, the secure DNS proxy
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin
NAME=stubby
DAEMON=/usr/bin/stubby
PIDFILE=/run/stubby.pid
CONFIG=/etc/stubby/stubby.yml
USER=stubby
test -f $DAEMON || exit 0
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting $NAME"
touch $PIDFILE
chown $USER $PIDFILE
chmod 700 $PIDFILE
start-stop-daemon --start --exec $DAEMON --pidfile $PIDFILE --chuid $USER --quiet --oknodo -- -C $CONFIG -g
log_end_msg $?
exit $?
;;
stop)
log_daemon_msg "Stopping $NAME"
start-stop-daemon --stop --exec $DAEMON --pidfile $PIDFILE --remove-pidfile --user $USER --quiet --oknodo
log_end_msg $?
exit $?
;;
restart)
$0 stop && $0 start
exit $?
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME"
exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
@socram8888
Copy link
Author

@no-systemd sure, go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment