ensuring ES gracefully finish and save metadata in every system shutdown
-
@meleu Thanks for stepping into this I think there also annother approach ;)
https://raw.githubusercontent.com/LowPowerLab/ATX-Raspi/master/shutdownchecksetup.sh
This install the watch GPIO script (Python and BASH - it's your choice!)and then here the shutdown script... That's very interesting!
https://lowpowerlab.com/guide/atxraspi/full-pi-poweroff-from-software/It's even using the NPN-hack for software powerdown ;)
So we can restart ES, reboot the system and shutdown ;)
I think the ATX Rasp works same as the mausberry ;)I don't want to mess this thread ... If there is a reason to step in we open a new thread ;)
-
@pjft Hi Thanks for getting back to me. I press the button to shutdown and when i reboot it has not saved the meta data. It is set to save. Doing from emulation station works.
-
@crazydude2 Let us talk here
-
@crazydude2 said in ensuring ES gracefully finish and save metadata in every system shutdown:
For some reason this didn't seem to work for me over ssh or using my atxraspi circuit. Any idea what i could have done wrong.
Hello mate. Sorry for the late replay, I was busy with Real Life stuff. I made intensive tests before posting that trick, then I would like to make it work for you.
I think it was my fault, because I didn't explicitly said to the user create the
/home/pi/bin
directory. It's implicit, but not very clear for inexperienced Linux users.Can you please paste here the output of these commands:
cat /home/pi/bin/killes.sh
... and paste the output here (don't forget to format your post, like @cyperghost showed you in your thread).
cat /etc/systemd/system/killes.service
... and paste the output here.
Have a nice day! :-)
-
Changelog: I've changed the script's path from
/home/pi/bin/
to/etc/
. Edited OP accordingly. -
@meleu Hi Thanks for getting back to me. I have found another solution which works but when i get more time i will set up a new image and give it a try. I am a bit worried about breaking it at the moment.
-
@meleu
Thanks for all the work you have put into this, I was excited when I was pointed to this thread, sadly this did not work for me though. I am using the Pololu mosfet board in a Retroflag/NESPi case. I followed your steps but it was very odd because when I powered down via the switch the power LED on the case remained lit (faintly) after the pi shut down. It also did not save the meta data when shutting down from ES or from an emulator. Does the script HAVE to be located in /etc/ ? -
@yahmez no. You can put it wherever you want (and adapt your
killes.service
file accordingly). Make sure to make the script executable (I forgot to mention this in the OP. Will update it soon.).chmod a+x /path/to/killes.sh
-
-
@cyperghost
I thought this would work for any shutdown script? 😜
Here it is: https://pastebin.com/25GKw9xv -
@meleu said in ensuring ES gracefully finish and save metadata in every system shutdown:
chmod a+x /path/to/killes.sh
Thank you, this got the script working. Only problem is the case LED remains faintly lit. I cannot figure this out... I mean everything shuts down, the fan turns off, but the LED is still getting a little bit of power. Somehow by using the killes script the mosfet switch stays on. The only thing that can keep it on after the power button is is turned off is a pi GPIO staying high. But then again it's not fully on because the pi and fan are off... it's puzzling. I added a GPIO.cleanup() line to the end of my script but it did not seem to matter.
-
After 5 minutes the LED fully extinguishes, so I guess this is a non issue even though it perplexes me. Thank you @meleu for working coming up with this graceful exit to ES. I really appreciate it.
-
@yahmez said in ensuring ES gracefully finish and save metadata in every system shutdown:
@cyperghost
I thought this would work for any shutdown script? 😜Yes. This is the intention of my approach here. ;)
I'm glad to know it's now working for you!
Have a nice weekend.
-
@yahmez Yes the solution from @meleu is working in general (thanks to him!)
... but I just want to take a look how the mass of these scripts are written. I'm currently working on annother way to shutdown and to give the user more control about the Pie.
One disadvantage will be that the shutdown scripts (bash, python or any other language) needs to be modified a bit. On the other hand, there will be no need to add something manually to systemd.
I don't know which method is better and I don't want to judge about. In the end the user decides on his own. The way how this script was born can be read on the first posting. And we can thank @meleu for his long breath and brillance in improve such scripts.
For me: It is always better to have two working ways ;)
Thanks for your help... -
@BuZz do you think it would be valuable to add the trick described in the OP as an option in
emulationstation.sh
script module?Summing up what it is: a way to ensure that ES will cleanly exit saving all metadata right before any shutdown/reboot.
If yes I can submit a PR for your evaluation.
EDIT: I'm thinking about an option like "Cleanly exit ES at any shutdown/reboot."
-
@meleu It's an issue with 3rd party reboot scripts? Looking briefly at op, I don't see why this is needed in RetroPie (it's not a RetroPie problem).
-
@buzz said in ensuring ES gracefully finish and save metadata in every system shutdown:
@meleu It's an issue with 3rd party reboot scripts?
Not only 3rd party reboot scripts, but any shutdown method different than ES quit menu (example: "Perform reboot" on retropie_setup while ES is running, or
shutdown -h now
orreboot
via SSH).Looking briefly at op, I don't see why this is needed in RetroPie
Before the "Favorites/Last Played" feature was implemented, the "save metadata on exit" wasn't so important. But now it is. It can be really frustrating to lose your favorites after spending some time curating the list...
RetroPie doesn't actually need this, but it would avoid several topics here in the forum with people asking for help on how to not lose Favorites/Last played data when shutting down the pi with power buttons like Mausberry, Powerblock, etc.
(it's not a RetroPie problem)
Well, I have no intention to label it as a "RetroPie problem", but here is a 100% clean RetroPie use case (no custom configs/hacks involved):
- Boot you raspi.
- In ES add some games to Favorites.
- Launch and exit some games (just to add some entries in the Last Played).
- Launch retropie_setup via RetroPie Menu in ES.
- Perform a reboot via retropie_setup.
- After rebooting check that your Favorites/Last Played wasn't saved.
IMHO adding that trick as an option in
emulationstation.sh
script module has more pros than cons. -
@meleu Well my advice would be to not reboot from retropie-setup and use ES. Maybe I should add a warning about rebooting when launched from ES. 3rd party reboot scripts can easily kill and wait for ES first. I'm not keen to invade the init system with ES to handle reboot scenarios outside of ES.
-
@buzz OK, I got it. Let's leave this as a tinker trick. I'm going to add this topic to the "Useful topics" post.
-
@buzz Well you can add a file "es-sysrestart" to folder tmp and send SIGTERM to EmulationStation-binary PID only - then this script provided with ES will takeover the shutdown sequence. If no active ES-PID is available the usual system shutdown can be performed.
Of course a warning hint within RetroPie-setup is also considerable and needs no maintainment - just a bit of user brain :)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.