Distinguish between reboot and halt/poweroff
-
Hi all,
I need to detect whether the device (Omega2S+) is rebooting or halting/poweroff in the shutdown section of an init.d script.
In other systems I use the output of the "runlevel" or "systemctl" commands.
I successfully added the busybox runlevel command to my image, but its output is always "Unknown"; I understand from the docs that the runlevel concept itself is not implemented in the OpenWrt OS.
Is there a way to accomplish what I want? If not possible in a script I'm also interested to implement it in a C program, using for example the libubus or libubox API.
Thank you.
-
For anyone interested, I ended up replacing the reboot command (that by default is a link to busybox) with a custom script that simply writes a file in the /tmp folder and then calls "busybox reboot".
-
@sarapg that's a clever, minimal solution