Safe shutdown for PI3

I understand Octoprint can be shutdown via the web interface. i would like to add a power button directly to the raspberry pi. i see that a shutdown.sh script is out there that some use for the retropie. I would like to add this function to the octoprint but if I add the shutdown.sh to the setting will anything break in the ocotprint program?

Thanks
Mike

Shouldn't. As long as you do a safe shutdown and not a hard shutdown. And of course, don't shut down when doing a print. As long as your soft power button is properly pulled to ground, you should not have any issues with false readings of the switch.

When you say add the shutdown script to OctoPrint, do you actually mean add it to the raspberry pi that's running OctoPrint? Or are you going to modify OctoPrint's source code somehow?

Reason I asked is I have a python script that checks for a button press in the background that shuts down my pi safely, doesn't require any sort of modification at all to OctoPrint so I'm a little confused as to what you're adding.

It may have been bad terminology on my part.
That is what I want to add to my setup. I know i need to use GPIO pins and add it to the Raspberry Pi, but just did not to mess up the octoprint "program" by adding something to it.
Thanks
Mike

You can run other programs along side it without too much issue as long as they don't take up too many system resources (running some sort of cpu intensive media encoding server would be a bad idea for example).

My solution was just a python script running in the background (started at boot via cron) that watched a certain GPIO pin and if it saw it get pulled up to 3.3v the script would call for a system shutdown in the same way you would if you were shutting down from the system terminal.

Just be aware that the GPIO pins on a raspberry pi are usually limited to 3.3 volts, make sure you don't accidentally connect your high side to one of the 5 volt pins.

I added a TP-Link Smart Plug to my setup. So after I tell the the computer to shutdown OctoPrint I then tell the computer to turn off the 3D printer.