Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Custom Script not running at startup despite following guidance...

    Recalbox General
    script running startup despite following
    3
    27
    9755
    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.
    • stigzler
      stigzler last edited by

      Hi. I'm trying to get a fan controller script running at startup. I've followed various approaches such as:

      https://github.com/recalbox/recalbox-os/wiki/Add-your-own-startup-script-(EN)
      https://forum.recalbox.com/topic/4370/help-with-starting-an-automatic-script-on-start-up
      https://forum.recalbox.com/topic/4157/gpio-rotary-volume/40

      None of which seem to work. 😞

      The test script:

      #!/usr/bin/env python
      
      import os
      import time
      import RPi.GPIO as GPIO
      
      print "Hello World Again"
      
      GPIO.setwarnings(False)
      GPIO.setmode(GPIO.BCM)
      GATE = 4
      GPIO.setup(4, GPIO.OUT)
      
      InitFlash = 0
      
      while InitFlash < 12 :
      	GPIO.output(GATE, True)
      	time.sleep(5)
      	GPIO.output(GATE, False)
      	time.sleep(3)
      	InitFlash += 1
      	
      print "bye!"
      

      For example, if I place this in : "share/system/custom.sh" and run manually via putty, the script works fine (toggling the gpio4 on and off). However, the script doesn't execute automatically at startup. I also tried placing it in the locations in the links above, but still no joy.

      Any ideas what's going wrong?

      Thanks

      Substring 1 Reply Last reply Reply Quote 0
      • lackyluuk
        lackyluuk Translator last edited by lackyluuk

        @stigzler I should finally write a Wiki article about this topic 😄
        Anyway..here some ideas:

        https://forum.recalbox.com/topic/3704/push-button-on-off-script-problems/10

        https://forum.recalbox.com/topic/8295/active-cooler-script-aber-wohin-und-wie-starten/7

        NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

        1 Reply Last reply Reply Quote 0
        • Substring
          Substring @stigzler last edited by

          @stigzler have you chmodded it to u+x at least ?

          Former dev - Please reply with @substring so that i am notified when you answer me
          Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

          stigzler 1 Reply Last reply Reply Quote 0
          • stigzler
            stigzler @Substring last edited by

            @substring If you mean custom.sh, then yes - I did that and makes no difference. Script doesn't run.
            thanks @lackyluuk - I'll take a look

            1 Reply Last reply Reply Quote 0
            • lackyluuk
              lackyluuk Translator last edited by lackyluuk

              @stigzler @Substring
              I wrote a Wiki for a fan control example and how to implement it. It's only available in German for now, but I will translate it soon to English 🙂

              https://github.com/recalbox/recalbox-os/wiki/Temperaturgeregelte-Lüftersteuerung-(DE)

              NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

              1 Reply Last reply Reply Quote 1
              • stigzler
                stigzler last edited by

                Looks awesome. I'll report back once had a go with it..

                Substring 1 Reply Last reply Reply Quote 0
                • Substring
                  Substring @stigzler last edited by

                  @stigzler dude,
                  move that code to a myuberscript.py, not inside custom.sh. And your custom.sh should be :

                  #!/bin/bash
                  python /path/to/myuberscript.py
                  

                  Former dev - Please reply with @substring so that i am notified when you answer me
                  Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                  1 Reply Last reply Reply Quote 0
                  • stigzler
                    stigzler last edited by

                    @Substring - Thanks. I see the logic behind that now..

                    However, tried it - still doesn't work. 😞

                    Both custom.sh and myuberscript.py (yes - kept the filename 😉 ) run OK independantly. However, script still doesn't appear to run on startup.

                    I checked S99custom in cd /etc/init.d and it matches the scripting here:

                    https://github.com/recalbox/recalbox-buildroot/blob/master/board/recalbox/fsoverlay/etc/init.d/S99custom

                    So I don't think it's that

                    I also chmod u+x both.

                    Would prefer this method over delving deeper into the image, as, if it works, it could be very straightforward. Any idea why the scripts aren't booting at startup despite that being their intended purpose?

                    1 Reply Last reply Reply Quote 0
                    • stigzler
                      stigzler last edited by

                      @lackyluuk - Your guide was great. Just google translated it + very straightforward. Thanks!

                      However, same issue! 😞

                      Scripts work when run individually, but doesn't run automatically at startup.

                      I'm really not sure what's going on. Any ideas? Might have to try a re-install at this rate.

                      1 Reply Last reply Reply Quote 0
                      • lackyluuk
                        lackyluuk Translator last edited by lackyluuk

                        @stigzler Does your script in /etc/init.d execute really without errors? Try to start this one. If you can start this without error, then it should work.

                        Do not start the fanControl.py script itself..start the onr, which starts then the fanControl.py

                        NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

                        1 Reply Last reply Reply Quote 0
                        • stigzler
                          stigzler last edited by

                          @lackyluuk - thanks for the quick reply. Yes, I put the script exactly as you put it in the wiki into init.d. Had to name it "S70StartFanControl.py" as S32 was already taken.

                          I executed this directly and it, in turn, called by full script. So I know both scripts work on their own.

                          There just seems to be a problem of startup scripts not being booted.

                          The only things I wonder about are:

                          I choose an external usb drive in recalbox (I have a USB3 drive connected to the Pi3). Dunno if that effects which scripts get called form where at startup?

                          My Pi seems to boot twice. I turn it on and it boots to the rainbow screen and a recalbox splash ("For recovery mode hold Shift"). It then powers down and re-boots to the normal boot screen and boots fine.

                          Any ideas?

                          Substring 1 Reply Last reply Reply Quote 0
                          • lackyluuk
                            lackyluuk Translator last edited by

                            @stigzler Booting from the USB Stick should'nt be a problem. I also use one and it starts all scripts properly from init.d

                            About the double booting issue I really have no idea.
                            If possible, you could try a clean install of recalbox. (Unfortunately the servers are down at the moment, so you cannot get the clean image I guess)

                            NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

                            1 Reply Last reply Reply Quote 0
                            • Substring
                              Substring @stigzler last edited by

                              @stigzler is your usb drive formatted as fat32 ?

                              Former dev - Please reply with @substring so that i am notified when you answer me
                              Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                              1 Reply Last reply Reply Quote 0
                              • Substring
                                Substring last edited by

                                One more suggestion : runbash -x /etc/ini.d/S99custom and paste here the output if you can't read it. I'm pretty sure it won't work because of fat32

                                Former dev - Please reply with @substring so that i am notified when you answer me
                                Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                                1 Reply Last reply Reply Quote 0
                                • stigzler
                                  stigzler last edited by

                                  @Substring:

                                  # bash -x /etc/init.d/S99custom
                                  + test -e /recalbox/share/system/custom.sh
                                  + /recalbox/share/system/custom.sh
                                  /etc/init.d/S99custom: /recalbox/share/system/custom.sh: /usr/bin/bash: bad interpreter: No such file or directory
                                  

                                  Does my USB3 drive need to be a different format? If so - what and how?
                                  thanks for both of your ongoing help

                                  1 Reply Last reply Reply Quote 0
                                  • stigzler
                                    stigzler last edited by

                                    @Substring
                                    Whoops! Spotted the silly error. Replaced

                                    #!/usr/bin/bash
                                    

                                    with

                                    #!/bin/bash
                                    

                                    "bash -x /etc/ini.d/S99custom" now run the script fine manually. However, still doesn't start at startup!!

                                    I't doing my head in this issue!

                                    Substring 1 Reply Last reply Reply Quote 0
                                    • Substring
                                      Substring @stigzler last edited by

                                      @stigzler can you add sime debugging echo to your custom.sh ? And paste your custom.sh script here ?

                                      Former dev - Please reply with @substring so that i am notified when you answer me
                                      Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                                      1 Reply Last reply Reply Quote 0
                                      • stigzler
                                        stigzler last edited by

                                        @Substring + @lackyluuk
                                        OK. To try and bottom this, I did a totally clean re-install and still not working. Here's my steps:

                                        • Formatted USB3 drive to FAT32 @ 4096 Cluster size (irrelevant as tested on SD card boot only)
                                        • Formatted the 32Gb Samsung SD card with SDCard Formatter
                                        • Installed fresh installation of recalbox + updated to 4.0.2 (higher updates still unavailable)
                                        • wrote a new custom.sh script in nano + placed in share\system
                                        • placed the script fanControl.py in the same directory. CHMod'd them both
                                        • Tested custom.sh via putty - works fine, displays "Launching Fan Control"
                                        • Tested fanControl.py individually via putty. Work as it should.
                                        • Restarted Recalbox. Neither script booted 😞

                                        Hmmm. This is soo frustrating! I thouhgt I'd hit gold with recalbox, as had tried other images to date, but this one stood head and shoulder above the rest. Until I hit this issue that is! And I need an image that can accommodate custom scripts.

                                        Below, my two scripts:

                                        Custom.sh:

                                        #!/bin/bash
                                        echo "Launching FanControl"
                                        python fanControl.py
                                        

                                        fanControl.py:

                                        here

                                        (I had to include this as a link as the pasted code caused this forum system to mark my post as Spam! Hopefully pastebin should be OK for you guys trusting links)

                                        That's as much 'out of the box' as I can make.. Any ideas?

                                        Substring 1 Reply Last reply Reply Quote 0
                                        • lackyluuk
                                          lackyluuk Translator last edited by

                                          @stigzler I really don't know what's wrong.
                                          But if you like you can try exactly what I did in the Wiki Article to have both scripts as .py scripts and use what I wrote in the S32StartFanControl as a subprocess

                                          Just for trying 🙂

                                          NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

                                          stigzler 1 Reply Last reply Reply Quote 0
                                          • Substring
                                            Substring @stigzler last edited by

                                            @stigzler You'd better tweak your custom.sh like :

                                            #!/bin/bash
                                            recallog "Launching FanControl"
                                            /usr/bin/python fanControl.py
                                            

                                            This way you'll find "Launching FanControl" in ~/logs/recalbox.log. If you do get the output, then it's a problem with python. Notice I added the full path to python, as I don't know how the $PATH looks like at that moment.

                                            Former dev - Please reply with @substring so that i am notified when you answer me
                                            Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Want to support us ?

                                            72
                                            Online

                                            98.6k
                                            Users

                                            28.1k
                                            Topics

                                            187.0k
                                            Posts

                                            Copyright © 2021 recalbox.com