Wanting custom scripts to run at start up and shutdown
-
I've written some scripts to transfer PSP save files to a USB and from the USB to the PSP save folder. They work when they are run manually however I would like for them to run automatically at start up and shutdown. How would I go about doing that?
Existing scripts:
Copy to Retropie (Want it to run at start up)#!/bin/bash cp -R /media/usb0/retropie-mount/Savefiles/PSP/SAVEDATA/* /opt/retropie/configs/psp/SAVEDATA/
Copy to USB (Want it to run at shutdown)
#!/bin/bash cp -R /opt/retropie/configs/psp/SAVEDATA/* /media/usb0/retropie-mount/Savefiles/PSP/SAVEDATA
Help would be much appreciated :D
-
@jmcdra Best way would be to edit
/opt/retropie/configs/all/autostart.sh
and then add your commands before and after the emulationstation call. -
Thank you :) I'll give it a try :D
-
The suggested solution by @cyperghost works until you rewrite the
autostart.sh
viaretropie_setup.sh
.Before
<statement A> emulationstation #auto <statement B>
After:
<statement A> <statement B> emulationstation #auto
Here's why (whatever should be 'autostarted' is added to the end of
autostart.sh
(>>
): retropie setup scriptsThe scripting functionality of emulationstation (scroll down to Scripting topic) has currently an event for "quit" - but not for "startup" (yet).
So either you refrain from rewriting your
autostart.sh
via theretropie_setup.sh
script
-or-
you put pre-emulationstation statements (<statement A>) inautostart.sh
and the post-emulationstation <statement B> commands into the/home/pi/.emulationstation/scripts/quit/
folder. In the latter case theautostart.sh
can safely be rewritten without messing the order as sketched above.You may table this in the "Ideas and development" section, if there is a general use for a "startup" event hook in emulationstation (so there is no more interference with the
retropie_setup.sh
rewrite ofautostart.sh
).Cheers
-
@Lolonois Thanks for pointing out
-
@Lolonois
To make sure I'm understanding you,my autostart.sh
should look like this:cp -R /media/usb0/retropie-mount/Savefiles/PSP/SAVEDATA/* /opt/retropie/configs/psp/SAVEDATA/ emulationstation #auto
And just move the post emulationstation script into a folder,
/home/pi/.emulationstation/scripts/quit/
and the system will know to run it at shutdown?All the stuff I'm seeing about shutdown scripts seems to be implying that you need to create a
.service
file. I'm not questioning your reasoning here, I'm just trying to understand the instructions so I don't delete my save files by accident.Thanks in advance! :)
-
@jmcdra The first part is right.
For the secon part put a script in
/home/pi/.emulationstation/scripts/quit/myquit.sh
and mark it executable (chmod a+x myquit.sh
). Or pick a more memorizable name formyquit.sh
.For testing I would start with a simple
touch /home/pi/touched_es_start
inautostart.sh
and in themyquit.sh
:touch /home/pi/touched_es_quit
.Start emulationstation as usual, wait a minute (or more), then quit ES. On the console check that the filenames (
touched_es_start
andtouched_es_quit
) have a timestamp that differs the time you waited (e.g. a minute or more).If this works out well, you did it right and can proceed with your script content.
Needless to say to stash away a backup of your precious data before you start this experiment if you are worried about losing/overwriting it accidentially.
Cheers
-
@Lolonois It worked! Thank you so much! That was so much simpler than all the stuff I was finding on google. I really appreciate it! :D
-
You're welcome.
On more thing: As a courtesy for other user here, please add [Solved] or similar to the topic of your original post.
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.