Start/Stop Script Ubuntu 16.04 [Help]

Paulo Roberto Tomasi pztomasi at gmail.com
Tue Dec 29 14:43:55 UTC 2020


Hi,

I need help about the start/stop/restart script for Ubuntu 16.04.7 LTS

I've installed unbound 1.13.0 from source:

* This link help me a lot:
http://linuxfromscratch.org/blfs/view/systemd/server/unbound.html

* Dependencies + make + make install were all succeeded
apt-get install make gcc libssl-dev libevent-dev libexpat1-dev libldns-dev

* group + user unbound created

* unbound + unbound-anchor + unbound-checkconf + unbound-control +
unbound-control-setup + unbound-host located at /usr/local/sbin

* unbound.conf installed at /etc/unbound/ with
parameter --with-conf-file=/etc/unbound/unbound.conf during configure

* then I've created the script /etc/init.d/unbound like this:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          unbound
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

NAME="unbound"
DESC="DNS server"
DAEMON="/usr/local/sbin/unbound"
PIDFILE="/run/unbound.pid"

HELPER="/usr/local/lib/unbound/package-helper"

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

# Override this variable by editing or creating /etc/default/unbound.
DAEMON_OPTS=""

if [ -f /etc/default/unbound ]; then
    . /etc/default/unbound
fi

case "$1" in
    start)
        log_daemon_msg "Starting $DESC" "$NAME"
        $HELPER chroot_setup
        $HELPER root_trust_anchor_update 2>&1 | logger -p daemon.info -t
unbound-anchor
        if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE
--name $NAME --startas $DAEMON -- $DAEMON_OPTS; then
            $HELPER resolvconf_start
            log_end_msg 0
        else
            log_end_msg 1
        fi
        ;;

    stop)
        log_daemon_msg "Stopping $DESC" "$NAME"
        if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
--name $NAME; then
            $HELPER resolvconf_stop
            log_end_msg 0
        else
            log_end_msg 1
        fi
        ;;

    restart|force-reload)
        log_daemon_msg "Restarting $DESC" "$NAME"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
--retry 5
        $HELPER resolvconf_stop
        if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE
--name $NAME --startas $DAEMON -- $DAEMON_OPTS; then
            $HELPER chroot_setup
            $HELPER resolvconf_start
            log_end_msg 0
        else
            log_end_msg 1
        fi
        ;;

    reload)
        log_daemon_msg "Reloading $DESC" "$NAME"
        if start-stop-daemon --stop --pidfile $PIDFILE --signal 1; then
            $HELPER chroot_setup
            log_end_msg 0
        else
            log_end_msg 1
        fi
        ;;

    status)
        status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
        ;;

    *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|status|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

#

But it didn't work:

service unbound start
Failed to start unbound.service: Unit unbound.service not found.

#

Did I forget something? =/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nlnetlabs.nl/pipermail/unbound-users/attachments/20201229/f495533f/attachment-0003.htm>


More information about the Unbound-users mailing list