Package: hostapd
Version: 2.4-1+deb9u3

https://salsa.debian.org/debian/wpa/blob/debian/2%252.4-1+deb9u2/debian/hostapd.init

        log_daemon_msg "Starting $DESC" "$NAME"
        start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \
                --pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
        log_end_msg "$?"

I.e. it fails to pass on the exit status from start-stop-daemon.  As a
result, *** when this specific version of hostapd is used with systemd
*** , "[ ok ]" is shown even if hostapd failed :

> # /etc/init.d/hostapd start
> [ ok ] Starting hostapd (via systemctl): hostapd.service.
> ...
> The error in journalctl -b -u hostapd is:
>     Starting advanced IEEE 802.11 management: hostapd failed!

The above is taken from the user report / support request at
https://unix.stackexchange.com/questions/518466/hostapd-hotspot-not-running

In Debian buster, this problem with systemd will be entirely solved,
because we now have hostapd.service, a native systemd service.  Yay!

However there is still this bug in the init script.  Other init
systems are available. These may rely on the old-style init.d scripts,
and may or may not give similarly confusing results.  So it would
still be nice to fix this bug.

I searched for a standard template for a Debian init script.  It turns
out /etc/init.d/skeleton went away, because simple scripts should now
be written using `init-d-script` .  There is a man page for it.  The
current man page is missing a lot of critical information, e.g.
forgets to mention how to pass arguments to the daemon :-( .  The
answers are in the source code, e.g. you can set DAEMON_ARGS.

The hack with "sleep 8" should be easy to re-create if necessary by
defining do_restart_override() and do_force_reload_override() .  I
guess that you are still finding it necessary, seeing as you have
defined RestartSec=2 in the systemd service.

source code link:
https://salsa.debian.org/debian/sysvinit/commit/fbf700964e86953d2c573229c39482db0b9e1eb7

---

There's a similar example showing how this init script incorrectly
shows "active" instead of "failed" in "systemctl status" :
https://github.com/raspberrypi/firmware/issues/1117 :

    # service hostapd status
    hostapd.service - LSB: Advanced IEEE 802.11 management daemon
       Loaded: loaded (/etc/init.d/hostapd; generated; vendor preset: enabled)
       Active: active (exited) since Wed 2019-02-27 21:05:29 UTC; 3s ago
         Docs: man:systemd-sysv-generator(8)
      Process: 2177 ExecStop=/etc/init.d/hostapd stop (code=exited,
status=0/SUCCESS)
      Process: 2212 ExecStart=/etc/init.d/hostapd start (code=exited,
status=0/SUCCESS)

    Feb 27 21:05:29 xxxxxxxx systemd[1]: Starting LSB: Advanced IEEE
802.11 management daemon...
    Feb 27 21:05:29 xxxxxxxx hostapd[2212]: Starting advanced IEEE
802.11 management: hostapd failed!
    Feb 27 21:05:29 xxxxxxxx systemd[1]: Started LSB: Advanced IEEE
802.11 management daemon.

Reply via email to