RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Mausberry Shutdown Script Doesn't Save Metadata

    Scheduled Pinned Locked Moved ControlBlock, PowerBlock & Co.
    mausberry
    251 Posts 10 Posters 96.8k 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.
    • hansolo77H
      hansolo77
      last edited by

      You guys are awesome. I haven't tried 1.5b (adding proper exit out of the loop) on my own system yet, but it sounds like you got it working. I hate not being home today to participate more. :) Thanks everybody! When I get a chance, I will put it into place and report back my own findings.

      Who's Scruffy Looking?

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

        @cyperghost

        bug report

        Our method to kill the command placed on the 4th line of /dev/shm/runcommand.info fails to kill ScummVM emulator. This is why:

        [prompt]$ sed -n 4p /dev/shm/runcommand.info
        bash /home/meleu/RetroPie/roms/scummvm/+Start\ ScummVM.sh "ft"
        

        Then our approach kills bash processes.

        I'm currently trying to find a strong solution. Will post it soon...

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

          @hansolo77 @lostless @cyperghost

          Can you guys test this one? Let's call it v1.7:

          #!/bin/bash -x
          # Before using this script you need to install inotify-tools:
          #
          #    sudo apt-get install inotify-tools
          #
          # I'm just trying to help with the script logic here.
          # I DON'T HAVE A MAUSBERRY AND DIDN'T TEST THE GPIO STUFF HERE!
          #
          #########################################################
          #  U S E   I T   A T   Y O U R   O W N   R I S K ! ! !  #
          #########################################################
          #
          # meleu - July/2017
          # kudos for @cyperghost , who is very persistent in help you guys! :-)
          
          #this is the GPIO pin connected to the lead on switch labeled OUT
          GPIOpin1=23
          
          #this is the GPIO pin connected to the lead on switch labeled IN
          GPIOpin2=24
          
          echo "$GPIOpin1" > /sys/class/gpio/export
          echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
          echo "$GPIOpin2" > /sys/class/gpio/export
          echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
          echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
          
          file="/sys/class/gpio/gpio$GPIOpin1/value"
          
          # up to here this code is executed at booting (/etc/rc.local)
          # let's wait for the creation of the "/sys/class/gpio/gpio$GPIOpin1/value"
          sleep 30 # not sure if 30 seconds is a good value...
          
          while inotifywait -qq -e modify "$file" ; do
              power="$(cat "$file")"
              [[ "$power" == 0 ]] && continue
          
              # explaining the crazy command below:
              # 1. get 4th line of runcommand.info (aka "emulator command")
              # 2. delete backslash '\' character
              # 3. replace every character that has a special meaning in a regex context with a dot '.'
              emu_command="$(sed -n 4p /dev/shm/runcommand.info | tr -d '\\"' | tr '^$[]*.()|+?{}' '.')"
              [[ -n "$emu_command" ]] && pkill -f "$emu_command" && sleep 10
          
              espid=$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")
              if [[ "$espid" ]]; then
                  touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown
                  kill "$espid"
                  exit
              fi
          
              sudo poweroff
          done
          

          I did a trick for debugging, then if this script doesn't work, please perform this command:

          grep 'rc\.local' /var/log/syslog > debug.log
          

          It creates a file named debug.log paste its conten in ghostbin.com or something similar.

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

            @meleu still did not work. I did the grep thing and can't find the syslog directory to find debug.log. also i don't have the /sys/class/gpio/gpio$GPIOpin1 directory. not sure if thats useful, but trying to help.

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

              @lostless please, paste here the output of these commands:

              ls -l /var/log/syslog
              

              and

              ls -lah /sys/class/gpio/*
              
              • Useful topics
              • joystick-selection tool
              • rpie-art tool
              • achievements I made
              lostlessL 1 Reply Last reply Reply Quote 0
              • lostlessL
                lostless @meleu
                last edited by

                first

                -rw-r----- 1 root adm 2281836 Jul 29 03:38 /var/log/syslog
                

                second

                -rwxrwx--- 1 root gpio 4.0K Jul 29 02:50 /sys/class/gpio/export
                lrwxrwxrwx 1 root gpio    0 Jul 29 02:50 /sys/class/gpio/gpio23 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio23
                lrwxrwxrwx 1 root gpio    0 Jul 29 02:50 /sys/class/gpio/gpio24 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio24
                lrwxrwxrwx 1 root gpio    0 Jul 29 02:50 /sys/class/gpio/gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
                lrwxrwxrwx 1 root gpio    0 Jul 29 02:50 /sys/class/gpio/gpiochip100 -> ../../devices/gpiochip2/gpio/gpiochip100
                lrwxrwxrwx 1 root gpio    0 Jul 29 02:50 /sys/class/gpio/gpiochip128 -> ../../devices/gpiochip1/gpio/gpiochip128
                -rwxrwx--- 1 root gpio 4.0K Jul 29 02:50 /sys/class/gpio/unexport
                
                meleuM 1 Reply Last reply Reply Quote 0
                • meleuM
                  meleu @lostless
                  last edited by

                  @lostless

                  now these:

                  cd
                  grep rc.local /var/log/syslog* > debug.log
                  ls -l debug.log
                  
                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  1 Reply Last reply Reply Quote 0
                  • lostlessL
                    lostless
                    last edited by lostless

                    -rw-r--r-- 1 pi pi 16656 Jul 29 03:44 debug.log
                    

                    i found a debug.log in the home (~) directory

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

                      @lostless open this file on your Windows (I'm assuming you're using Windows), select all text and paste on ghostbin.com

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

                        @meleu nope mac. I can boot into windows if need be.

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

                          @lostless nop, I just need you to copy the entire file

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

                            @meleu
                            its just

                            /var/log/syslog:Jul 23 06:28:29 genepi systemd[1]: Starting /etc/rc.local Compatibility...
                            /var/log/syslog:Jul 23 06:28:29 genepi systemd[1]: Started /etc/rc.local Compatibility.
                            

                            over and over with different dates and times. nothing else.

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

                              @lostless now I need you to do the same thing for /etc/rc.local and /etc/switch.sh (the last one is supposed to be my v1.7 script, but please, paste it on ghostbin so I can really check if everything is fine)

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

                                /etc/rc.local
                                https://ghostbin.com/paste/goucc

                                /switch.sh
                                https://ghostbin.com/paste/5agap

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

                                  @lostless

                                  ls -l /etc/switch.sh
                                  
                                  • Useful topics
                                  • joystick-selection tool
                                  • rpie-art tool
                                  • achievements I made
                                  1 Reply Last reply Reply Quote 0
                                  • lostlessL
                                    lostless
                                    last edited by

                                    @meleu said in Mausberry Shutdown Script Doesn't Save Metadata:

                                    ls -l /etc/switch.sh

                                    -rwxrwxrwx 1 root root 1889 Jul 29 02:42 /etc/switch.sh
                                    
                                    meleuM 1 Reply Last reply Reply Quote 0
                                    • meleuM
                                      meleu @lostless
                                      last edited by meleu

                                      @lostless
                                      damn! I'm not getting what's wrong! Let's try this:

                                      sudo bash -x /etc/switch.sh & 2> /home/pi/script-debug.txt
                                      

                                      And then press the f%#&ing button. Pretty please... :)

                                      It should turn off your pi...

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

                                        @meleu aaaaaaaaaaaaaannnnnnnddddd...................

                                        ...........NO GOOD. >:( sorry man.

                                        1 Reply Last reply Reply Quote 0
                                        • lostlessL
                                          lostless @meleu
                                          last edited by

                                          @meleu

                                           + GPIOpin1=23
                                          + GPIOpin2=24
                                          + echo 23
                                          /etc/switch.sh: line 22: echo: write error: Device or resource busy
                                          + echo in
                                          + echo 24
                                          /etc/switch.sh: line 24: echo: write error: Device or resource busy
                                          + echo out
                                          + echo 1
                                          + file=/sys/class/gpio/gpio23/value
                                          + sleep 30
                                          + inotifywait -qq -e modify /sys/class/gpio/gpio23/value
                                          

                                          the readout of that and its stuck. My terminal has not finished what its doing.

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

                                            @lostless are you able to use IRC? maybe it's better than this forum for an online conversation... :P

                                            edit I'm at #retropie at irc.freenode.net

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