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
@no-systemd
Copy link

no-systemd commented Oct 14, 2024

I installed stubby from the Devuan repo on Excalibur via apt. The package came with a systemd service file only.
Thank you for your sysv-init script!
Would it be possible to communicate your script to the Devuan packager team?

P.S. One little suggestion. Add please "--background" in line 30.
I used your script in a LXC container and stubby attached to a tty. So i could not detach console from the LXC container.
After adding "--background" stubby is started without attaching to a tty.

Thank you so much again!

@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