RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    How to restart ES from a script?

    Scheduled Pinned Locked Moved Help and Support
    scriptessystems.cfgrestart
    111 Posts 5 Posters 41.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • meleuM
      meleu @TMNTturtlguy
      last edited by meleu

      @TMNTturtlguy looks like a problem on your script, because I tested my solution to restart ES using a script inside RetroPie Menu with only the command yo restart es and everything runs flawlessly several times in a row.

      • Useful topics
      • joystick-selection tool
      • rpie-art tool
      • achievements I made
      cyperghostC 1 Reply Last reply Reply Quote 1
      • cyperghostC
        cyperghost @meleu
        last edited by cyperghost

        @meleu --- wrong ---
        Sorry wrong issue

        @TMNTturtlguy
        But I also think that it has something to do with your script because all solutions posted by meleu, @BuZz and mine results in the same mechanism to kill one specific process.

        Not more not less

        1 Reply Last reply Reply Quote 0
        • meleuM
          meleu @TMNTturtlguy
          last edited by

          @TMNTturtlguy @cyperghost prepare for another EUREKA moment. :-)

          However I still have issue when pressing start to go to the menu and then to either restart ES or shudown system. In both cases it just flashing my script and then restarts ES. The only way to get rid of this is to Kill the highest number ES and sudo touch and then sudo rm /tmp/es-restart

          That commit BuZz made on RetroPie-Setup was exactly to avoid this problem. But I think I've found the bug on your script...

          Here is what is happening:

          • before that commit, the scripts launched via RetroPie menu were executed as root. Therefore the touch /tmp/es-restart/ was creating a file owned by root.
          • the emulationstation processes are all started by the pi user.
          • one of those emulationstation processes is a script responsible to rm /tmp/es-restart at some point, but as the script is being executed by the pi user, it can't remove a file owned by root, i.e. it fails to remove /tmp/es-restart.
          • emulationstation always restarts if there's a file named /tmp/es-restart, and as this file wasn't removed, emulationstation is always restarting on your tests.

          What BuZz made in that commit was exactly make the scripts launched via RetroPie menu be executed by the pi user. But the @TMNTturtlguy 's script makes this fix ineffective because it's doing sudo touch /tmp/es-restart. This means that the /tmp/es-restart file will be owned by root and the problem I described above still happens.

          Got it? :-)

          By the way, @TMNTturtlguy I've submitted a PR to your little repository: https://github.com/TMNTturtleguy/change_es_systems/pull/1

          • Useful topics
          • joystick-selection tool
          • rpie-art tool
          • achievements I made
          cyperghostC TMNTturtlguyT 2 Replies Last reply Reply Quote 1
          • cyperghostC
            cyperghost @meleu
            last edited by cyperghost

            @meleu .... So mine worked for him because I force remove es-restart via sudo

            meleuM 1 Reply Last reply Reply Quote 0
            • meleuM
              meleu @cyperghost
              last edited by meleu

              @cyperghost yep, but as you can see here in emulationstation.sh, removing the /tmp/es-restart shouldn't be a user's task.

              That emulationstation.sh is the piece of code responsible to manage what happens with the user's choice on ES Quit menu (restart ES, quit ES, restart system, shutdown system).

              • Useful topics
              • joystick-selection tool
              • rpie-art tool
              • achievements I made
              cyperghostC 1 Reply Last reply Reply Quote 0
              • TMNTturtlguyT
                TMNTturtlguy @meleu
                last edited by

                @meleu thanks so much! Gotta get the kids to daycare, will test out in about 45 minutes.

                1 Reply Last reply Reply Quote 0
                • cyperghostC
                  cyperghost @meleu
                  last edited by

                  @meleu said in How to restart ES from a script?:

                  @cyperghost yep, but as you can see here in emulationstation.sh, removing the /tmp/es-restart shouldn't be a user's task.

                  That emulationstation.sh is the piece of code responsible to manage what happens with the user's choice on ES Quit menu (restart ES, quit ES, restart system, shutdown system).

                  EUREKA

                  1 Reply Last reply Reply Quote 0
                  • TMNTturtlguyT
                    TMNTturtlguy
                    last edited by

                    @meleu I merged your changes and loaded into my pi, the script fails t launch. I noticed a few things:

                    • the menu dialog functions were not present
                    • the script that was on github was not updated to reflect the permission changes per the retropie setup script changes. sudo needs to be added in front of the rm and cp commands now. I hadn't updated because that was the last working script using @cyperghost command.

                    I took your modifications and merged them with the dialog text and the sudo commands and i still get the same issue. When i go to the start menu, select quit, and then any function i see a flash of script and a restart. This newer code does not seem to change anything.

                    I have added a second branch, branch v2 to the github repository. github v2 If you and @cyperghost could look at the v2 script and possibly download it and try to run it from the retropie menu that would be great.

                    Thank you both for your time and help.

                    meleuM cyperghostC 2 Replies Last reply Reply Quote 0
                    • meleuM
                      meleu @TMNTturtlguy
                      last edited by

                      @TMNTturtlguy I will only have a chance to look at it tomorrow... But I'll try. Cheers!

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      TMNTturtlguyT 1 Reply Last reply Reply Quote 1
                      • TMNTturtlguyT
                        TMNTturtlguy @meleu
                        last edited by

                        @meleu Not a problem! No rush, I appreciate all the help. Thanks

                        1 Reply Last reply Reply Quote 0
                        • cyperghostC
                          cyperghost @TMNTturtlguy
                          last edited by cyperghost

                          @TMNTturtlguy I think first @meleu should take a look on your script. If there are still issues with it then I build a "restart binary" based on my script but that will analyze processes and kills always the right one ... so there are no future issue okay?

                          But I think Master meleu finds an easy solution....

                          TMNTturtlguyT 1 Reply Last reply Reply Quote 1
                          • TMNTturtlguyT
                            TMNTturtlguy @cyperghost
                            last edited by

                            @cyperghost i agree! I appreciate both of your guys help. In the mean time i will keep tinkering with it and the script works fine without the auto restart function. You just have to manually restart, so for the time being I can still accomplish what I want.

                            meleuM 1 Reply Last reply Reply Quote 0
                            • meleuM
                              meleu @TMNTturtlguy
                              last edited by

                              @TMNTturtlguy out of curiosity: you need a keyboard to choose an option on your script, right? Or is it able to get input from joystick?

                              • Useful topics
                              • joystick-selection tool
                              • rpie-art tool
                              • achievements I made
                              TMNTturtlguyT 1 Reply Last reply Reply Quote 0
                              • TMNTturtlguyT
                                TMNTturtlguy @meleu
                                last edited by

                                @meleu the way it is written now it works from joystick/controller. The whole point is that i want to be able to make the ES changes without a keyboard. It works great right now with joystick and ps4 controller, less the restart issues. Thanks

                                meleuM cyperghostC 2 Replies Last reply Reply Quote 0
                                • meleuM
                                  meleu @TMNTturtlguy
                                  last edited by

                                  @TMNTturtlguy said in How to restart ES from a script?:

                                  @meleu the way it is written now it works from joystick/controller.

                                  This is curious. I can't see any mention to joy2key in your script. And joy2key is the tool responsible to convert the up/down/left/right on d-pad to up/down/left/right key presses (and A button to <enter>).

                                  Can you confirm that you navigate through your dialog menu using the up/down in your joystick and select an option with the button A?

                                  • Useful topics
                                  • joystick-selection tool
                                  • rpie-art tool
                                  • achievements I made
                                  1 Reply Last reply Reply Quote 0
                                  • cyperghostC
                                    cyperghost
                                    last edited by

                                    @meleu
                                    Yes It's working with D-Pad A and B
                                    even this minimal menu works

                                    #!/bin/bash
                                    # Bash Menu Script Example
                                    
                                    dialog --clear --backtitle "Backtitle here" --title "Title here" --menu "Choose one of the following options:" 15 40 4 \
                                    1 "Option 1" \
                                    2 "Option 2" \
                                    3 "Option 3"
                                    
                                    meleuM 1 Reply Last reply Reply Quote 1
                                    • cyperghostC
                                      cyperghost @TMNTturtlguy
                                      last edited by cyperghost

                                      @meleu @TMNTturtlguy @BuZz Man I'm so ....
                                      pkill -n emulationstatio always kills the newest process that the short version what my script exactly does. With all advantages and disadvantages - but the shortest script ;)

                                      I should more RTFM

                                      1 Reply Last reply Reply Quote 0
                                      • meleuM
                                        meleu @cyperghost
                                        last edited by

                                        @cyperghost said in How to restart ES from a script?:

                                        @meleu
                                        Yes It's working with D-Pad A and B

                                        Really neat! :-) It seems to be a cool RetroPie feature, because if you launch the script directly from command line you can't use joystick for that.

                                        pkill -n emulationstatio always kills the newest process that the short version what my script exactly does. With all advantages and disadvantages - but the shortest script ;)

                                        Maybe we can make a video like this below replacing pumpkin by emulationstation:

                                        • Useful topics
                                        • joystick-selection tool
                                        • rpie-art tool
                                        • achievements I made
                                        cyperghostC 1 Reply Last reply Reply Quote 1
                                        • cyperghostC
                                          cyperghost @meleu
                                          last edited by

                                          @meleu Is this always the same pumpkin? I think a pumpkin always got's seven lives.

                                          meleuM 1 Reply Last reply Reply Quote 0
                                          • meleuM
                                            meleu @cyperghost
                                            last edited by meleu

                                            @cyperghost said in How to restart ES from a script?:

                                            @meleu Is this always the same pumpkin? I think a pumpkin always got's seven lives.

                                            I think one is a binary, two or three are scripts, and the others were launched in an infinite loop inside some of those scripts.

                                            • Useful topics
                                            • joystick-selection tool
                                            • rpie-art tool
                                            • achievements I made
                                            mediamogulM 1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last 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.