[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

Unread post by alexandros301 » Thu Jul 20, 2017 1:07 am

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?

User avatar
mad_ady
Posts: 6178
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 123 times
Been thanked: 88 times
Contact:

Re: "poweroff" doesn't work headless

Unread post by mad_ady » Fri Jul 21, 2017 1:38 am

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

Unread post by alexandros301 » Fri Jul 21, 2017 2:54 am

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?

User avatar
mad_ady
Posts: 6178
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 123 times
Been thanked: 88 times
Contact:

Re: "poweroff" doesn't work headless

Unread post by mad_ady » Fri Jul 21, 2017 1:16 pm

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

Unread post by alexandros301 » Fri Jul 21, 2017 11:44 pm

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

Unread post by alexandros301 » Sat Jul 22, 2017 12:04 am

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

Unread post by skullboy » Sun Aug 20, 2017 7:21 pm

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

Unread post by alexandros301 » Sun Aug 20, 2017 7:46 pm

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