Posts by Rembrandt

    mglae's post #12's link to a solution worked for me; I just changed "exec /bin/sh" to "exec /bin/bash" but followed the other instructions to the letter. Thanks!

    frakkin64's ping idea: duh, again, I use it to find computers that come online, so I could have used it for computers going offline/powering down too.

    ghtester, thanks, I had considered a 433MHz transmitter in the Pi and power sockets as a potential follow-up to this, but that's another subject for another time.

    Thank you all!

    OK forum, thank you so far.

    To recap, I'm trying to run a custom script as Kodi "Power Off System" is clicked on a RPi-4 under LibreELEC.

    I now have the following code.

    /storage/.config/shutdown.sh which has execute rights :

    Code
    -rwxr-xr-x    1 root     root           474 Jan 16 10:40 /storage/.config/shutdown.sh

    shutdown.sh :

    The "power-off" case does not seem to get triggered and I do not want it in all-other cases.

    When I run the above ( power-off case) code in a script, saved as a sh file, directly from the command line, it works each and every time.

    That was from Raspbian - I have to correct some things - I apologise.

    Code corrected.

    Do I perhaps need to enable the use of the shutdown.sh ?

    Perhaps I have to add the full paths to each command in the shutdown.sh script ?

    BR

    Rembandt

    Thanks JoeAverage,

    The code that runs in cron @reboot is:

    Code
    while [ $( ps aux | grep -v grep | grep -c kodi ) -eq 2 ] ; do sleep 1; done; /storage/bin/RunScriptAtKodiPowerDown.sh

    I could use pgrep instead, had forgotten about it.

    However, I think that the order of shutting down services/deamons/processess etc prevents this from ever exiting the while-loop, i.e. the above BASH code gets 'unloaded', removed from memory before the while condition ever reaches "not-equal". This is a hunch.

    Perhaps there is another way to do this?

    BR

    Rembrandt


    PS: EDIT 1

    I suspect running / starting my script at power-down needs to be organised differently, so that the RPi does not keep shutting down parts of the OS etc as my BASH script is still running, i.e. my script would need to be run between the signal to power down and the start of the actual power-down procedure.

    Hello forum,


    I would like to run a custom BASH script as the user chooses to power-down Kodi via the GUI.


    The script uses variable assignment, the date fuction, netcat and a while/do loop.


    I know cron cannot be used for running scripts at/before shutdown.


    I'm running Kodi 19.3 Matrix on a 4GB RPi with LibreELEC 10.0.1.


    Thanks for your time.


    Best regards,

    Rembrandt


    PS: EDIT 1 this does not work - tested

    Would I be able to start a BASH script via cron @reboot that checks ps aux | grep kodi

    for the likes of :

    1067 root 0:00 {kodi.sh} /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs

    1081 root 7:59 /usr/lib/kodi/kodi.bin --standalone -fs

    and if these, or one of them disappear, assume that Kodi is going down?

    Thanks.

    Hello people,

    I've got a 4Gb RPi4 too and use it almost exclusively for KODI/LibreELEC.

    Would the changes the original poster mentioned have any noticable effects, and where would these be most obvious?

    Thanks.

    Problem:

    KODI or LibreELEC stops recognizing powered USB2.0 hub - i.e. USB hub port light go off and connected USB mouse etc stop working.


    Symptoms - intermittent:

    During the NOOBS OS selection menu, the mouse is available and the lights on the powered USB2.0 hub are all on - even unused ports.

    When selecting to start KODI, during KODI boot the lights of the USB2.0 hub go off and on again after which the main menu screen of KODI appears.

    Now, right away or after a while, the port lights on the USB2.0 hub all go off causing everything connected to that port to become unavailalble.

    The USB2.0 hub port lights don't come on again until the Pi is powered off and on by taking its power away.

    During all this the D-Link USB2.0 hub power indicator light remains on, just the individual port lights all go off.

    This happens on both Pi4 USB 2.0 ports.

    This also happened before I had the Sabrent USB audo card connected.

    The D-Link USB2.0 hub has no issues on my Windows 7 PC, connected to nano receiver, external HD and other peripherals.

    Please see below for hardware and software details . I still have to capture a log, but can not do so when the problem occurs as KODI starts.

    * UPDATE 11 Jan: The issue persists when I remove the keyboard and portable HD from the USB2.0 hub.


    Question:

    What would cause KODI (or LibreELEC) to stop recognizing the powered USB2.0 hub?


    Thanks for your time.

    Regards,
    A.



    Hardware:

    Raspberry Pi4 with 4 Gb and official power supply

    D-Link powered USB2.0 7-port hub connected to Pi USB2.0 port using original D-Link cable.

    Plugged into D-Link USB2.0 hub are:

    • nano mouse receiver
    • wired keyboard
    • Sabrent external USB sound card
    • Removable portable hard disk

    The second Pi4 USB2.0 port is unused

    Other Pi4 connections:

    • LAN, one HDMI in use - nearest to power plug, powered USB3.0 hub on one USB3.0 port (for 6 x powered external SATA drive), other USB3.0 port unused.

    Software:

    LibreELEC (offical) 9.2.0 (kernel: linux 4.19.83)

    Build KODI 18.5 Git:Leia_pi4_18.5-Leia

    Compiled 2019-11-23

    NOOBS installation of KODI on 128Gb Sandisk Extreme uSD card, next to Raspbian.

    I have SSH access to LibreELEC if needed.