[SOLVED] "poweroff" doesn't work headless

Moderators: mdrjr, odroid

[SOLVED] "poweroff" doesn't work headless

Unread postby 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?
alexandros301
 
Posts: 28
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3

Re: "poweroff" doesn't work headless

Unread postby 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.
User avatar
mad_ady
 
Posts: 2870
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2

Re: "poweroff" doesn't work headless

Unread postby 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?
alexandros301
 
Posts: 28
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3

Re: "poweroff" doesn't work headless

Unread postby 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
User avatar
mad_ady
 
Posts: 2870
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2

Re: "poweroff" doesn't work headless

Unread postby 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: 28
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3

Re: "poweroff" doesn't work headless

Unread postby 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!
alexandros301
 
Posts: 28
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3

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

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

Thanks for this perfect working solution, i really appreciate :D :lol:
skullboy
 
Posts: 2
Joined: Sun Aug 20, 2017 6:57 pm
Location: New York
languages_spoken: english

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

Unread postby 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).
alexandros301
 
Posts: 28
Joined: Sun Aug 31, 2014 5:31 pm
languages_spoken: english
ODROIDs: ODROID-U3


Return to Issues

Who is online

Users browsing this forum: No registered users and 1 guest