Bonno Bloksma:
I recommend less guessing and more reading your own posts. (-: You yourself posted the very script fragment where the script itself runs the test command twice: 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 } See where that runs From the LSB: prefix to the service name in the very
log output that you posted, we can deduce that systemd is
running your van Smoorenburg Put another way: There is no customizable mechanism to make the very execution of the start, stop, and restart commands in systemd dependent from first testing some arbitrary service-specific condition. There's no way to tell systemd "only actually execute the restart command at all if this shell script first returns true". When running restart, systemd will stop your service, start it again, and the test in the script will only then run as part of your service's initialization. The best that you have are mechanisms that cause a startup to
abort, by failing an ExecStartPre command. But for
those you must actually write a proper service unit file. |