HW Shutdown/Reboot Switch

Raspberry Pi related support

HW Shutdown/Reboot Switch

Postby RussellS » 13 Apr 2015, 19:35

Hi, I am building a media streamer based around a Raspberry Pi (Model B) and RuneAudio and part of the project involves having a hardware button to startup, shutdown & reboot the system. To perform this I am using the ATXRasPi (http://lowpowerlab.com/atxraspi/#whatisit). However this requires a script to run at startup which monitors two of the GPIO pins which the ATXRasPi board is connected to. The script setup provided by the board manufacturer is written to run under Raspbien and is run from the 'rc.local' file.

No it appears that ArchLinux (which RuneAudio is based on) does not support 'rc.local' so even though I have the script installed and the setup file has created the 'rc.local' file the script is not being run at boot time.

Basically, what I want to know is how do I go about running the script at boot. I currently have the script file 'shutdowncheck.sh' in the /etc folder and if I ssh into the system and run 'bash /etc/shutdowncheck.sh' the script runs and the hardware power button performs as it should. Obviously I am logged in as root so the script is being excecuted with elevated priveledges and so because the script is performing shutdown and reboot commands when the script is excecuted at boot it would also need to be excecuted as root.


If anyone could help with this I would be grateful.

Many thanks
RussellS
 
Posts: 8
Joined: 05 Apr 2015, 16:28

Re: HW Shutdown/Reboot Switch

Postby hondagx35 » 13 Apr 2015, 20:34

Hi RussellS,

try this:

- store this file in /usr/lib/systemd/system
- name it like atxraspi.service
Code: Select all
[Unit]
Description=Startup ATXRasPi
After=systemd-modules-load.service

[Service]
Type=oneshot
ExecStart=/usr/bin/bash /etc/shutdowncheck.sh

[Install]
WantedBy=multi-user.target


- invoke "systemctl enable atxraspi" from console
Code: Select all
systemctl enable atxraspi


- reboot

Frank
User avatar
hondagx35
 
Posts: 3041
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: HW Shutdown/Reboot Switch

Postby RussellS » 13 Apr 2015, 22:01

Thanks very much for your help Frank,

That appears to have done the trick


Russell,
RussellS
 
Posts: 8
Joined: 05 Apr 2015, 16:28

Re: HW Shutdown/Reboot Switch

Postby RussellS » 14 Apr 2015, 17:21

I think I was a bit premature in saying that it was all ok I'm afraid.

Basically, the 'shutdowncheck.sh' script is launching fine at boot and the hardware shutdown button is working fine. However, after issuing the command 'systemctl enable atxraspi' RuneAudio stops playing music, it dissapears as a DLNA renderer and RuneUI stops talking to the system and just gives a spinning wheel. If I then issue the command 'systemctl disable atxraspi' immediately RuneUI reconnects and all is fine again.

If I launch the 'shutdowncheck.sh' script manually from an ssh login then there are no problems. So it seems to be running the script as a system service that is causing the problem.
RussellS
 
Posts: 8
Joined: 05 Apr 2015, 16:28

Re: HW Shutdown/Reboot Switch

Postby hondagx35 » 14 Apr 2015, 20:36

Hi Russel,

sorry this my mistake i should have taken a look at the script first.
The shutdowncheck.sh runs a endless loop (while(1)), so it never stops.

So i think i told you the wrong service type.
Please try
Code: Select all
[Service]
Type=simple


Frank
User avatar
hondagx35
 
Posts: 3041
Joined: 11 Sep 2014, 22:06
Location: Germany

Re: HW Shutdown/Reboot Switch

Postby thva » 14 Aug 2015, 11:39

Hello

Is your ATXRASPI works after the script Changes ?

ATXRaspi.service

[Unit]
Description=Startup ATXRasPi
After=systemd-modules-load.service

[Service]
Type=simple
ExecStart=/usr/bin/bash /etc/shutdowncheck.sh

[Install]
WantedBy=multi-user.target
thva
 
Posts: 5
Joined: 14 Aug 2015, 10:22

support RuneAudio Donate with PayPal


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 1 guest