nadenislamarre I have added the next "echo":
#!/bin/bash
# Horrible script
# will kill kodi when it's thread are < 8
# because it the number of threads hanging
# when you try to quit after seeing a movie
# and letting the process hang
systemsetting="python /usr/lib/python2.7/site-packages/configgen/settings/recalboxSettings.pyc"
WAITMODE="`$systemsetting -command load -key kodi.network.waitmode`"
echo "1"
# if the mode is required or wish,
# kodi waits for the network before starting
# in fact, it waits that an ip is available (such as a db service for example)
if test "${WAITMODE}" = "required" -o "${WAITMODE}" = "wish"
then
echo "2"
WAITTIME="`$systemsetting -command load -key kodi.network.waittime`"
WAITHOST="`$systemsetting -command load -key kodi.network.waithost`"
DOCONT=1
NWAITED=0
while test "${DOCONT}" = 1
do
if ping -c 1 "${WAITHOST}" -W 3
then
DOCONT=0
else
sleep 1 # wait, in case the host is not correct
let NWAITED=$NWAITED+4
if test "${NWAITED}" -gt "${WAITTIME}"
then
DOCONT=0
if test "${WAITMODE}" = "required"
then
exit 1
fi
fi
fi
done
fi
# recreate a fifo to get kodi events and be sure it's empty
rm -f /var/run/kodi.msg
if ! mkfifo /var/run/kodi.msg
then
echo "3"
exit 1 # code for error
fi
(
echo "3_1"
LD_LIBRARY_PATH="/usr/lib/mysql" /usr/lib/kodi/kodi.bin --standalone -fs
echo "Kodi process ended." >&2
echo "EXIT" >> /var/run/kodi.msg # in case of normal, but mainly anormal end of kodi, send a message to signal the end
)&
kodiLastChance() {
sleep 3 # kodi, please take less than X seconds to quit
if ps -o comm | grep -qE '^kodi.bin$'
then
echo "4"
sleep 2 # let some other seconds to kodi to quit
killall -9 kodi.bin
fi
}
while read EVENT
do
echo "EVENT: ${EVENT}"
echo "Kodi event : ${EVENT}" >&2
case "$EVENT" in
"EXIT")
echo "5"
kodiLastChance
wait
exit 0 # code for success
;;
"RESTART")
echo "6"
kodiLastChance
wait
exit 10 # code to reboot
;;
"SHUTDOWN")
echo "7"
kodiLastChance
wait
exit 11 # code to shutdown
;;
esac
done < /var/run/kodi.msg
echo "8"
rm -f /var/run/kodi.msg
echo "Kodi launcher ended without event." >&2
exit 1
### end ###
#
I have seen that sometimes kodi is not closing, in those moments the log show this:
---- recalbox-config.sh ----
[ 10.73] : Starting S92switch
[ 10.73] : script /recalbox/scripts/powerswitch.sh [ STARTED ]
[ 10.85] : Starting S94manager
Will not start pm2 : system.api.enabled is set to 0
[
{ "code":1, "width":1920, "height":1080 }
When kodi close the log is including kodilauncher.sh (and my logs)
---- recalbox-config.sh ----
[ 10.42] : Starting S92switch
[ 10.43] : script /recalbox/scripts/powerswitch.sh [ STARTED ]
[ 10.55] : Starting S94manager
Will not start pm2 : system.api.enabled is set to 0
[
{ "code":1, "width":1920, "height":1080 }
]
[
{ "code":1, "width":1920, "height":1080 }
]
['/recalbox/scripts/kodilauncher.sh']
1
3_1
EVENT: EXIT
5
I think that the problem is not kodilauncher.sh, maybe there is another script calling kodilauncher.sh producing this behaviour.
Regards!