systemd problems on Raspian Buster - radicale, isc-dhcp-server, sshd, apache2
After reboot, radicale and isc-dhcp-server don't start. Or, rather, radicale starts and then exits.
apache2 and sshd ports have been configured so that ssh over port 80 to a separate ip number is possible
sshd starts but not all ports are assigned
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 22 on 2001:8b0:7c:1::154 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 22 on 90.155.48.154 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 443 on 2001:8b0:7c:1::136 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 80 on 2001:8b0:7c:1::136 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 90.155.48.136 port 443.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 90.155.48.136 port 80.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 81.187.211.34 port 22.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 2001:8b0:7c:1::138 port 22.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 22 on 90.155.48.138 failed: Cannot assign requested address.
apache 2 fails to start
The radicale, isc-dhcp-server and apache2 problems are detectable using "systemctl show" as the failure is detectable
LoadState=loaded
ActiveState=active
SubState=exited
I've created a root cron job to run, probably, once a day, to check and restart if neccessary, the services
For example, for radicale
#!/bin/bash
# Run with root crontab once each day
# --------------------------------------------------------------------------
# radicale shows on reboot:
# LoadState=loaded
# ActiveState=active
# SubState=exited
/bin/echo "Checking radicale"
/bin/systemctl show radicale.service | /bin/grep -i SubState=running
radicale_rc=${?}
if [[ ${radicale_rc} -ne 0 ]]; then
/bin/echo "radicale not running"
/bin/systemctl restart radicale.service
/bin/systemctl show radicale.service | /bin/grep -i SubState=running
radicale_rc=${?}
if [[ ${radicale_rc} -eq 0 ]]; then
/bin/echo "radicale running"
fi
else
/bin/echo "radicale running"
fi
It is more difficult to check the sshd error as sshd is started. I'm using a rather dirty hack of checking if apache2 is running and, if not, restart sshd.
apache2 and sshd ports have been configured so that ssh over port 80 to a separate ip number is possible
sshd starts but not all ports are assigned
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 22 on 2001:8b0:7c:1::154 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 22 on 90.155.48.154 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 443 on 2001:8b0:7c:1::136 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 80 on 2001:8b0:7c:1::136 failed: Cannot assign requested address.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 90.155.48.136 port 443.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 90.155.48.136 port 80.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 81.187.211.34 port 22.
Jul 27 14:51:04 arcticus sshd[536]: Server listening on 2001:8b0:7c:1::138 port 22.
Jul 27 14:51:04 arcticus sshd[536]: error: Bind to port 22 on 90.155.48.138 failed: Cannot assign requested address.
apache 2 fails to start
The radicale, isc-dhcp-server and apache2 problems are detectable using "systemctl show" as the failure is detectable
LoadState=loaded
ActiveState=active
SubState=exited
I've created a root cron job to run, probably, once a day, to check and restart if neccessary, the services
For example, for radicale
#!/bin/bash
# Run with root crontab once each day
# --------------------------------------------------------------------------
# radicale shows on reboot:
# LoadState=loaded
# ActiveState=active
# SubState=exited
/bin/echo "Checking radicale"
/bin/systemctl show radicale.service | /bin/grep -i SubState=running
radicale_rc=${?}
if [[ ${radicale_rc} -ne 0 ]]; then
/bin/echo "radicale not running"
/bin/systemctl restart radicale.service
/bin/systemctl show radicale.service | /bin/grep -i SubState=running
radicale_rc=${?}
if [[ ${radicale_rc} -eq 0 ]]; then
/bin/echo "radicale running"
fi
else
/bin/echo "radicale running"
fi
It is more difficult to check the sshd error as sshd is started. I'm using a rather dirty hack of checking if apache2 is running and, if not, restart sshd.