# The default ubuntu unbound service uses SysV fallback mode, we want a proper unit file so unbound gets restarted correctly

[Unit]
Description=Unbound DNS Resolver
After=network-online.target
Before=nss-lookup.target
Wants=network-online.target nss-lookup.target

[Service]
PIDFile=/run/unbound.pid
# https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html ("Special Excecutable Prefixes")
# update the root anchor after a out-of-disk-space situation (see #269)
# it returns 1 even on fail, it's not clear - https://unbound.docs.nlnetlabs.nl/en/latest/manpages/unbound-anchor.html#exit-code
ExecStartPre=-/usr/sbin/unbound-anchor -a /var/lib/unbound/root.key
ExecStart=/usr/sbin/unbound -d
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
Type=notify

[Install]
WantedBy=multi-user.target
