shivasiddharth
Posts: 7
Joined: Thu Aug 24, 2017 12:05 pm

Service to Safe Shutdown Headless Raspberry Pi Boards

Tue Sep 19, 2017 11:16 am

Everytime when you need to shutdown headless Pi boards, either you need to plugin a monitor or SSH into the Pi. By connecting a pushbutton across GPIO and by running a service, now you can safe shutdown and restart Pi boards.

1. Clone the git:

Code: Select all

git clone https://github.com/shivasiddharth/pi-shut
2. Run the installer.

Code: Select all

sudo chmod +x /home/pi/pi-shut/installer.sh  
sudo /home/pi/pi-shut/installer.sh  
3. Wire the Pi as per the diagram.
Image

4. Start the shutdown service.

Code: Select all

 sudo systemctl start on-off-pushbutton.service
Now, you have the service to safe shutdown and restart pi working.

RonR
Posts: 95
Joined: Tue Apr 12, 2016 10:29 pm

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 4:29 am

The capability to shutdown and restart a Raspberry Pi using a normally open momentary pushbutton switch connected to GPIO pins 5 & 6 is already present in Raspbian Stretch and requires no additional software. To enable it:

1. Add the following line to /boot/config.txt:

dtoverlay=gpio-shutdown

2. Run rpi-update

Depressing the pushbutton on a running system will shut it down as if you had issued "shutdown -h now".

Depressing the pushbutton on a halted system will restart the system.

User avatar
rpdom
Posts: 11521
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 4:46 am

RonR wrote:
Wed Sep 20, 2017 4:29 am
The capability to shutdown and restart a Raspberry Pi using a normally open momentary pushbutton switch connected to GPIO pins 5 & 6 is already present in Raspbian Stretch and requires no additional software. To enable it:

1. Add the following line to /boot/config.txt:

dtoverlay=gpio-shutdown

2. Run rpi-update

Depressing the pushbutton on a running system will shut it down as if you had issued "shutdown -h now".

Depressing the pushbutton on a halted system will restart the system.
FTFY :D

RonR
Posts: 95
Joined: Tue Apr 12, 2016 10:29 pm

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 5:01 am

rpdom wrote:
Wed Sep 20, 2017 4:46 am
2. Run rpi-update
....
FTFY :D
You obviously didn't do any testing before posting. The firmware and/or kernel included in the latest Stretch image has to be updated for this feature to function properly.

User avatar
rpdom
Posts: 11521
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 5:32 am

RonR wrote:
Wed Sep 20, 2017 5:01 am
rpdom wrote:
Wed Sep 20, 2017 4:46 am
2. Run rpi-update
....
FTFY :D
You obviously didn't do any testing before posting. The firmware and/or kernel included in the latest Stretch image has to be updated for this feature to function properly.
Yes I did. It worked perfectly.

Do not run rpi-update unless one of the Foundation experts tells you to. It can easily break things.

RonR
Posts: 95
Joined: Tue Apr 12, 2016 10:29 pm

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 6:05 am

rpdom wrote:
Wed Sep 20, 2017 5:32 am
Yes I did. It worked perfectly.
I'm betting you didn't test it running on a USB drive. An rpi-update is required.

User avatar
rpdom
Posts: 11521
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 6:09 am

RonR wrote:
Wed Sep 20, 2017 6:05 am
rpdom wrote:
Wed Sep 20, 2017 5:32 am
Yes I did. It worked perfectly.
I'm betting you didn't test it running on a USB drive. An rpi-update is required.
No. I didn't. The OP didn't specify a USB drive, so I didn't see the point.

I don't have time to test with a USB drive right now, and am not sure why you brought up the subject.

User avatar
DougieLawson
Posts: 29715
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 7:52 am

RonR wrote:
Wed Sep 20, 2017 4:29 am

2. Run rpi-update
What does running rpi-update give you that isn't in the stock, standard, stable Raspbian Stretch kernel & bootcode?

Why do folks persist in suggesting that rpi-update is needed to enable standard facilities.

It installw the latest experimental kernel and untested experimental firmware. It can leave your raspberry unbootable (it has done on mine). If you aren't an expert or a kernel developer or able to restore an unbootable system in 20 minutes and aren't willing to work with the RPF folks to fix their bugs then DO NOT run rpi-update.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

User avatar
rpdom
Posts: 11521
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Service to Safe Shutdown Headless Raspberry Pi Boards

Wed Sep 20, 2017 8:38 am

rpdom wrote:
Wed Sep 20, 2017 6:09 am
RonR wrote:
Wed Sep 20, 2017 6:05 am
rpdom wrote:
Wed Sep 20, 2017 5:32 am
Yes I did. It worked perfectly.
I'm betting you didn't test it running on a USB drive. An rpi-update is required.
No. I didn't. The OP didn't specify a USB drive, so I didn't see the point.

I don't have time to test with a USB drive right now, and am not sure why you brought up the subject.
Now I have tested it using a USB stick and it still works.

An rpi-update is not required.

Return to “Beginners”

Who is online

Users browsing this forum: gkreidl and 35 guests