Restart/shutdown through OctoPrint's system menu dosn't work

What is the problem?

Hi everybody,

hopefuly im in the right channel for the related topic.

I set up arch linux and installed octoprint thru AUR (https://aur.archlinux.org/packages/octoprint-venv/). As far as i can say, otoprint is running well. But there is one Problem for me relataed to the execusion of shutdown commands thru OctoPrint's system menu.

What did you already try to solve it?

In Settings > Commands

i configured the following commands:

  • Restart OctoPrint: sudo service octoprint restart
  • Restart system: sudo shutdown -r now
  • Shutdown system: sudo shutdown -h now

I also tried the commands:

  • Restart OctoPrint: sudo systemctl restart octoprint
  • Restart system: sudo systemctl reboot
  • Shutdown system: sudo systemctl poweroff

When i choose one of the options OctoPrint brings up the message:

Success

The command "*******" executed successfully

But after that messages nothing happens. Can somebody point me in the right direction? Im totally new to linux and also to Octoprint, so please dont get angry when i not can follow as fast as you want.

Logs (octoprint.log, serial.log or output on terminal tab, browser error console ...)

octoprint.log (135.6 KB)

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ...)

OctoPrint : 1.3.11
Installed: 1.3.11
Available: 1.3.11 (stable release)

If you look at the code involved in the OctoPi image, it includes at least two entries in the /etc/sudoers.d folder related to the pi user being able to sudo these activities without providing the root password.

If you've managed to install OctoPrint using a different method, you would need to create something similar on yours.

Hi Guru, and thank you for trying to help. I made the the following entries to my /etc/sudoers

rynr ALL =NOPASSWD: /usr/bin/systemctl poweroff,/usr/bin/systemctl halt,/usr/bin/systemctl reboot,/usr/bin/systemctl restart octoprint

When I execute one of these commands from the terminal of my Linux all works without prompted to entering a password.

Is there a way to see if the command is send to the system after hitting the button in octoprint?

So I found a solution.

after a bit of sleep I thought i give it a new try.

I executed one of the shutdown commands thru OctoPrint's system menu. After this I opened a Terminal window and typed in:

systemctl status octoprint

In the output I could see that the user was not in the list of sudo. At this Moment I recognised that octoprint in my case is a user too.

So I changed my entry in /etc/sudoers to:

octoprint AtomicPi =NOPASSWD: /usr/bin/systemctl poweroff,/usr/bin/systemctl reboot,/usr/bin/systemctl restart octoprint

Also I edited the commands in OctoPrint:

  • Restart OctoPrint: sudo systemctl restart octoprint
  • Restart system: sudo systemctl reboot
  • Shutdown system: sudo systemctl poweroff

At the moment it is working fine and hopefully it will stay this way.

4 Likes

I have the same issue after running a backup from a thin client. Can you help with a rather novice linux user? I tried editing etc/sudoers but at the top of the file it states that this is not advised and I should edit sudoers.d instead. Can you point to where the commands for shutdown can be altered in octoprint?

Hi all:

Like a root, I wrote this command and worked so fine:

echo "USERNAME ALL=NOPASSWD: /usr/bin/systemctl poweroff,/usr/bin/systemctl reboot,/usr/bin/systemctl restart octoprint" > /etc/sudoers.d/octoprint-cmd

USERNAME is the user name you made for octoprint installation (pi in a Raspberry Pi native instalation). No need to reboot to work.

Many thanks for the info: it helped me a lot.