acpid: use shutdown for poweroff, if available, not /sbin/poweroff
authorCarlos Santos <casantos@datacom.com.br>
Thu, 30 Aug 2018 13:21:20 +0000 (10:21 -0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 10 Sep 2018 19:10:10 +0000 (21:10 +0200)
It's preferable to use "shutdown -hP now" to ensure that the runlevel is
known, preventing this message on the system console and log:

  WARNING: could not determine runlevel - doing soft poweroff
    (it's better to use shutdown instead of poweroff from the command line)

Signed-off-by: Carlos Santos <casantos@datacom.com.br>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/acpid/acpid.mk

index 33e87cf50ac65b7d5f5ff73ec29bb48610ca20d1..48fe005e5e1104a69c4f320f3f17c5a1c8f130df 100644 (file)
@@ -15,9 +15,15 @@ define ACPID_INSTALL_INIT_SYSV
                $(TARGET_DIR)/etc/init.d/S02acpid
 endef
 
+ifeq ($(BR2_INIT_SYSV)$(BR2_INIT_SYSTEMD),y)
+ACPID_POWEROFF_CMD = /sbin/shutdown -hP now
+else
+ACPID_POWEROFF_CMD = /sbin/poweroff
+endif
+
 define ACPID_SET_EVENTS
        mkdir -p $(TARGET_DIR)/etc/acpi/events
-       printf "event=button[ /]power\naction=/sbin/poweroff\n" \
+       printf 'event=button[ /]power\naction=%s\n' '$(ACPID_POWEROFF_CMD)' \
                >$(TARGET_DIR)/etc/acpi/events/powerbtn
 endef