Skip to content

Make power commands customizable and update related documentation  #132

@infeeeee

Description

@infeeeee

From #131:

On some linux distros (e.g. Raspbian 12 Bookworm) poweroff --wtmp-only does not fail as expected, and wrong command is selected for reboot and poweroff.

TODO:

  • Make the power commands editable, e.g. poweroff is the default, but user can change it manually to sudo poweroff or whatever they like. Current methods can be used to select the defaults on Linux.
  • Documentation: Recommend users to add a polkit rule instead of updating a sudoers file. This way IoTuring can call power commands without sudo. E.g. /etc/polkit-1/rules.d/49-power-nopasswd.rules for user pi:
polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
        action.id == "org.freedesktop.login1.power-off-multiple-sessions" ) &&
        subject.user == "pi")
    {
        return polkit.Result.YES;
    }
});

On an automatic installation this should be placed in /usr/share/polkit-1/rules.d instead of /etc. It's much safer to edit this, recently messed up my sudoers and it was not easy to get back control.

  • @richibrics Does something similar exist on macos? Something more modern and fine-grained than editing the sudoers file?
    • Quick search says running osascript -e 'tell application "System Events" to shut down' and similar commands work without sudo Source
      Maybe they could be the defaults, andd users can manually change them to the sudo version if they set up sudoers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions