Web lists-archives.com

Re: dhcp restart with bad config




On 2017-08-29, Bonno Bloksma <b.bloksma@xxxxxx> wrote:
> Hi,
>
> Today I had a small (big?) problem with the DHCP server.
> When I make any changes I allways do a
> # service isc-dhcp-server restart
> to test the new config. In the past when there was an error in the config the service would keep running using the previous config.
> This was achieved by doing a config test before the service stop.
>
> On my old Wheezy machine the /etc/init.d/isc-dhcp-server file has the segment(s)
> [...]
> test_config()
> {
>         if ! /usr/sbin/dhcpd -t $OPTIONS -q -cf "$DHCPD_CONF" > /dev/null 2>&1; then
>                 echo "dhcpd self-test failed. Please fix $DHCPD_CONF."
>                 echo "The error was: "
>                 /usr/sbin/dhcpd -t $OPTIONS -cf "$DHCPD_CONF"
>                 exit 1
>         fi
> }
> [...]
> restart | force-reload)
>                 test_config
>                 $0 stop
>                 sleep 2
>                 $0 start
>                 if [ "$?" != "0" ]; then
>                         exit 1
>                 fi
>                 ;;
> Where a failed test_config will result in stopping the restart.
>
> On my Jessie DHCP servers this safeguard no longer seems to be present.
> After a typo in the config my DHCP server stopped and did not come up until I fixed the typo and (re)started the service. Which took a while as I got disturbed and the change was not urgent and I assumed the service was still running :-(
>
> Is there any way to get the old functionality back?
>
> Bonno Bloksma

You could port the script segments you identified to the jessie version
of the init file. But first I would consult the changelog from the
wheezy to the jessie versions (especially with regard to systemd
migration) to see if there is a better way.

-- 

Liam