[SOLVED] "poweroff" doesn't work headless

Post Reply
alexandros301
Posts: 38
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3
Has thanked: 0
Been thanked: 0
Contact:

[SOLVED] "poweroff" doesn't work headless

Post by alexandros301 »

I've build a synthesizer with an Odroid-U3 running Pure Data (Pd). I'm using a Teensy for the control, and one of the momentary switches is used to power off the Odroid. I've run this to be able to run "poweroff" without sudo:

Code: Select all

sudo chmod a+s /sbin/poweroff
so when I keep the momentary switch held down for two seconds, on release Pd sends "poweroff" to the shell and the Odroid shuts down. This happens though only when I'm SSHing to the Odroid. When the whole thing runs headless it won't work. Is there a catch that I don't know?

mad_ady
Posts: 8319
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 573 times
Been thanked: 434 times
Contact:

Re: "poweroff" doesn't work headless

Post by mad_ady »

How do you run Pure Data? Is it a daemon? Do you run it in your ssh terminal? If yes, then it closes when you close ssh, so it can't interpret poweroff. You need to run it as a daemon, or inside a screen/tmux session.

alexandros301
Posts: 38
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3
Has thanked: 0
Been thanked: 0
Contact:

Re: "poweroff" doesn't work headless

Post by alexandros301 »

mad_ady wrote:How do you run Pure Data? Is it a daemon? Do you run it in your ssh terminal? If yes, then it closes when you close ssh, so it can't interpret poweroff. You need to run it as a daemon, or inside a screen/tmux session.
I'm running it without the GUI through a bash script. To be honest, I don't really understand what a deamon is, so I can't really answer your question.
The idea is that it runs headless, without a screen or laptop attached to it. It does run and the synthesizer works as expected, but it just can't power off the Odroir. As I wrote in the OP, "poweroff" is called by a Teensy sending a specific message to Pd when I press a certain momentary switch for a couple of seconds. The "poweroff" message is sent to the [shell] object which talks to the shell. When I've SSHed into the Odroid the whole thing runs fine, only when headless it's not working.

So, I guess I'm not running it as a deamon, right? How can I do that?

mad_ady
Posts: 8319
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 573 times
Been thanked: 434 times
Contact:

Re: "poweroff" doesn't work headless

Post by mad_ady »

You could invest time and read on how to create a systemd service to run a bash script, or use the quick and dirty way of starting screen before your script:

Code: Select all

screen -R -D
./script.sh

alexandros301
Posts: 38
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3
Has thanked: 0
Been thanked: 0
Contact:

Re: "poweroff" doesn't work headless

Post by alexandros301 »

mad_ady wrote:You could invest time and read on how to create a systemd service to run a bash script, or use the quick and dirty way of starting screen before your script:

Code: Select all

screen -R -D
./script.sh
I've written this in crontab:

Code: Select all

@reboot sleep 20 ; screen -R -D ; sh /home/odroid/scripts/launch_jack_pd.sh
But it didn't do the job. I guess I've have to read how to create a systemd service to run a bash script. Any suggested readings?

alexandros301
Posts: 38
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3
Has thanked: 0
Been thanked: 0
Contact:

Re: "poweroff" doesn't work headless

Post by alexandros301 »

Ok, did with by adding "sudo" in the message sent from Pd to the shell! Even though I can run "poweroff" in the terminal without sudo as used odroid, this won't apply to the Pure Data patch, even if I'm running Pd again as used odroid.
Anyway, problem solved.
Thanks for your answers!

skullboy
Posts: 2
Joined: Sun Aug 20, 2017 6:57 pm
languages_spoken: english
Location: New York
Has thanked: 0
Been thanked: 0
Contact:

Re: [SOLVED] "poweroff" doesn't work headless

Post by skullboy »

Thanks for this perfect working solution, i really appreciate :D :lol:
Last edited by skullboy on Mon Feb 19, 2018 12:46 am, edited 2 times in total.

alexandros301
Posts: 38
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3
Has thanked: 0
Been thanked: 0
Contact:

Re: [SOLVED] "poweroff" doesn't work headless

Post by alexandros301 »

skullboy wrote:Thanks for this perfect working solution, i really appreciate :D :lol:
Not sure how ironic your comment is but it's not the standard situation for powering off the Odroid.
The thing is that I 'm calling "poweroff" from inside Pure Data, not from a terminal, and I'm not asked for a password, I couldn't even type a password, the whole application runs headless and I'm using a push-button to run this command, hence it's not the "standard" way to power off a computer, that's why I was initially trying to power it off without needing to type a password (check OP).

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 1 guest