udm-le: unifi-os doesn't restart

Expected With the on-boot script, udm-le waits 5 minutes then installs certs and restarts unifi-os

Actual The unifi-os restart command that the script runs doesn’t work. Unifi-os is stopped but doesn’t restart, everything is back to normal only after manually executing unifi-os restart.

UDM-PRO firmware 1.8.6 on-boot-script 1.0.4 udm-le 1.0.7

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 36 (16 by maintainers)

Most upvoted comments

Yeah, that was never going to work.

Not really, I was wrong there. The -x switch does work but the output is written to syslog at /var/log/messages and not to the file we specified, the file remains empty.

I did some further testing. I created an on boot script that contained only

wait 600
unifi-os restart

It failed the same way udm-le fails. So it’s clearly something with on boot scripts execution on my udm-pro.

I narrowed down the problem further by modifying my script to sh -x /usr/sbin/unifi-os restart and inspecting /var/log/messages.

unifi-os restart calls the stop function first which is as follows:

stop() {
	if ! container_is_running "${CONTAINER_NAME}"; then
		echo "${CONTAINER_NAME} is not running"
	else
		echo "Stopping ${CONTAINER_NAME}"
		podman stop "${CONTAINER_NAME}"
	fi
	stop_dropbear_daemon
}

According to the logs I saw, podman stop is the last command that executes, stop_dropbear_deamon or the restart function that should be called later are never executed. This is because the script receives a SIGTERM.

Mar 15 21:52:09 unifi user.notice unifi-os: + stop
Mar 15 21:52:09 unifi user.notice unifi-os: + container_is_running unifi-os
Mar 15 21:52:09 unifi user.notice unifi-os: + podman inspect -f '{{.State.Running}}' unifi-os
Mar 15 21:52:09 unifi user.notice unifi-os: + '[' true '=' true ]
Mar 15 21:52:09 unifi user.notice unifi-os: + echo 'Stopping unifi-os'
Mar 15 21:52:09 unifi user.notice unifi-os: Stopping unifi-os
Mar 15 21:52:09 unifi user.notice unifi-os: + podman stop unifi-os
Mar 15 21:52:15 unifi syslog.info kernel: [  333.980562] systemd-journald[26]: Received SIGTERM from PID 1 (system
d-shutdow).
Mar 15 21:52:15 unifi user.emerg kernel: [  333.982681] reboot: cmd=cdef0123
Mar 15 21:52:15 unifi user.emerg kernel: [  333.986192] reboot:   called by: [ 2122]/lib/systemd/systemd-shutdown
halt --timeout 90000000us --log-level 6 --log-target console --log-color
Mar 15 21:52:15 unifi user.emerg kernel: [  333.999053] reboot:   called by: [ 2108]/usr/libexec/podman/conmon --a
pi-version 1 -c 4c2e68e3a60876d796608aa35e9c4e9e2ccf9417127022a8c4ca0b96e5512619 -u 4c2e68e3a6087
Mar 15 21:52:15 unifi user.emerg kernel: [  334.014347] reboot:   called by: [    1]init
Mar 15 21:52:15 unifi user.emerg kernel: [  334.018642] reboot:   called by: [    0]

You can see that just after podman stop unifi-os the script receives a SIGTERM, it then finishes shutting down unifi-os and exits. This never happens when unifi-os restart is run from command line. I have absolutely no idea where this is comming from, I think I’m going to ask on udm-utilities issues.