Execute script on shutdown by timer

  • Hello


    I use LibreELEC 8.0.1 with the vu+ pvr client. Most of the time I want to shutdown the pvr server (a linux box in another room), when I shutdown LibreELEC. This works with the approach from thread-107-post-1367.html#pid1367


    If I shut down LibreELEC with the menu entry in the log out menu (or the mapped key on my remote), the shutdown_with_net.sh script is executed and everything works as expected. But if I try to shutdown with a timer (e.g. set the timer to 5 min), the script is not called.
    The regular shutdown.sh approach also does not work, because I have to execute the script before the network of LibreELEC is disconnected and shutdown.sh is called after the network is disconnected. The same applies to the KODI Callback addon, if I execute a regular shutdown, everything works as expected, but if I try a shutdown timer, the script is not called.


    Does someone here have a working solution to call a script when LibreELEC shuts down by timer or is this a problem in KODI, that shutdown by timer and shutdown by menu entry don't call the same events


    Thanks
    zehner

  • I don't have an answer but can't your run a script on the pvr server to ping your kodi box(es) and if the ping is not successful after a number of attempts/minutes (i.e. Denouncing reboots, network glitches) then shut it down?

  • I tried using shutdown_with_net.service and it worked also when using shutdown timer from kodi.

    Done giving support here because of last events.

  • Thanks for the feedback and thanks vpeter for the shutdown_with_net service in general. I have no clue about systemd, so your work was a lifesaver for me


    You are right, the script is also executed with shutdown timer. I have integrated some logging and can see the script is executed. The script has no dynamic parts and its the same script, so I have no clue why it's working if called by button and not working if called by timer. At least now I know that everything works in LibreELEC and I have to search on server side


    Thanks

  • zehner, put content of your file on pastebin web page and maybe we can see why it fails.

    Done giving support here because of last events.

  • Thanks vpeter, but pastebin would be using a sledgehammer to crack a nut.


    There is only one command in my file
    [code=php]
    wget powerstate?newstate=0
    [/php]
    This command sends a standby to my pvr. I will try a few params, curl instead of wget, ip instead of url and check the return value, perhaps that gives me a clue whats wrong when using a timer


  • Thanks vpeter, but pastebin would be using a sledgehammer to crack a nut.


    Haha...


    For testing I had 20 ping's to some server and I saw all 20 of them on it. Meaning network was available to send pings.
    Your command should also work fine. No idea why it fail.

    Done giving support here because of last events.