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.
I realise this should perhaps be asked at the LibreELEC forum ?
Thanks for your time.
Best regards,
Rembrandt
Yes, it would be better on their support forum.
There are triggers for Kodi quiting that could be exploited, but it might be better done in the underlying OS layer.
Thank you DarrenHill,
I looked at " /usr/lib/systemd/system/kodi-poweroff.service ", but that still scares me.
I'll head over to the LibreELEC forum; fingers crossed.
BR
Rembrandt
Thanks DaVu,
I started a thread on the LibreELEC forum as well.
I will check-out your links too, thank you.
Rembrandt
PS - Still not working as a shutdown.sh script in /storage/.config (it does have execute rights for root)
(The while conditions come across wrongly here; it's ok in my 'edit' - had to insert a space between the brackets to make it show correctly.)
Code:
#! /bin/bash
case "$1" in
halt)
# your commands here
;;
poweroff)
IP="111.222.333.444"
port=7294
msg="Message-01"
timeout="10 seconds"
let endtime=$(date +%s)+$timeout
echo "$msg" | nc -w 1 "$IP" $port
ec=$?
while [ [ $(date -u +%s) -le $endtime ] ] && [ [ $ec -ne 0 ] ] ; do
echo "$msg" | nc -w 1 "$IP" $port
ec=$?
done
;;
reboot)
# your commands here
;;
*)
# your commands here
;;
esac
Running just the "poweroff" case as an individual sh file from the command line works every time.
That was running on Raspbian - I need to correct a few lines here. I am sorry but will be back.
Code corrected
Perhaps I have to add the full paths to each command in the shutdown.sh script ?
EDIT:
Networking gets shutdown before shutdown.sh is handled!