Rpi hangs when using autostart.sh

  • I want to execute a shell script when libreelec boots.

    Tried @reboot in cron but seems not supported.

    Then found autostart.sh... I added with nano the path to script and did 755 on autostart.sh.

    At reboot rpi is stuck after rainbow splash. Tried filezilla ssh and deleted autostart.sh but the device keeps hanging.

    Any quick fix for this?

    I'm on 9.0.1

  • autostart.sh is run at the start of the userspace boot process and if you want things to happen in the background you will need to (background)& the commands. If your script fails un-gracefully it can block the boot process.

  • OK but its deleted so there should be no more access at boot?

    JerryPenguin

    The script loads a m3u playlist from my dropbox folder for simple iptv ;)

    It gets executed 3 times a week and to be safe i need it fresh after some boot.

  • You seem to want to download your m3u file over the internet.

    My guess is that at that time either no network is available or for some reason Dropbox is not available.

    If you comment out this command, does LE continue?

    Can you manually download the m3u list via SSH?

  • Seems like filezilla deleted not correctly but with ssh terminal it worked.

    Don't know what was going wrong but i had forgot I put a systemctl restart kodi at the end so pvr simple reloads the playlist after download when executed from cron.

    I made this new script without the kodi restart

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

    Now the rpi boots fine but only line that is executed is the delete old playlist command.

    Like you mentioned seems like dropbox at this time is not reachable but ethernet and ssh is up.

    Next problem i guess would be that I need a short delay for pvr simple to wait loading playlist befor script is finfished.

    Any suggestions? :)

  • Solution...

    I did

    (

    sleep 5

    ) &

    /storage/.kodi/myscript.sh &

    exit

    but sleep won't get recognized.

    So I put sleep befor dropbox download in myscript.sh. I figured out that sleep 1 is time enough to get online and download before pvr simple loads the file.

    Sleep 6 takes too long so pvr simple stays empty then. Anything between sleep 1 and 5 should be fine.

  • I had a similar problem with my WiFi, which I have solved now.

    The built-in function in LE: "Waiting for the network" did not work there either.

    Here I used the following script in autostart.sh:

    So I wasn't dependent on a fixed sleep count anymore and with timetowait I don't get into an endless loop.

  • Thank you both.

    With autostart.sh I struggled a bit. Putting sleep in background has no effect... hmm.

    Also I don't understand why to execute some command in background and then execute the script. Or is the script then executed in background too because of the backgrounded commands before? :)

    And for what reason does @reboot in cron not work?

    Just for my understanding. :)

  • You use the sleep command to pause within a script.

    If you put the command in the background, the next command is executed in the script and the sleep command has no effect.

    On my LE SBC I don't use crontab, so I can't tell you why @reboot doesn't work there.

    On my PC with Fedora and CentOS @reboot works fine.

  • @things are not supported in cron from busybox.

    More crontab @reboot command in LE

    In autostart.sh just add sleep command for few seconds or make better way until network is really up (like loop until file is succcesfully downloaded) and then download file. Don't put this commands in background.

    Loop like