X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=cirros-testvm%2Fsrc-cirros%2Fbuildroot-2015.05%2Fpackage%2Fkodi%2Fbr-kodi;fp=cirros-testvm%2Fsrc-cirros%2Fbuildroot-2015.05%2Fpackage%2Fkodi%2Fbr-kodi;h=83d4d4e5ac3b5e845bc43ecc28768db2325a1923;hb=b0a0f15dfaa205161a7fcb20cf1b8cd4948c2ef3;hp=0000000000000000000000000000000000000000;hpb=c6ac3cd55ee2da956195eee393b0882105dfad4e;p=packages%2Ftrusty%2Fcirros-testvm.git diff --git a/cirros-testvm/src-cirros/buildroot-2015.05/package/kodi/br-kodi b/cirros-testvm/src-cirros/buildroot-2015.05/package/kodi/br-kodi new file mode 100755 index 0000000..83d4d4e --- /dev/null +++ b/cirros-testvm/src-cirros/buildroot-2015.05/package/kodi/br-kodi @@ -0,0 +1,36 @@ +#!/bin/sh + +# We're called with the real Kodi executable as +# first argument, followed by any Kodi extra args +KODI="${1}" +shift + +# In case someone asked we terminate, just kill +# the Kodi process +trap_kill() { + LOOP=0 + killall "${KODI##*/}" +} +trap trap_kill INT QUIT TERM + +LOOP=1 +while [ ${LOOP} -eq 1 ]; do + # Hack: BusyBox ash does not catch signals while a non-builtin + # is running, and only catches the signal when the non-builtin + # command ends. So, we just background the Kodi binary, and wait + # for it. But BusyBox' ash's wait builtin does not return the + # exit code even if there was only one job (which is correct + # for POSIX). So we explicitly wait for the Kodi job + "${KODI}" "${@}" & + wait %1 + ret=$? + case "${ret}" in + 0) ;; + 64) poweroff; LOOP=0;; + 66) reboot; LOOP=0;; + *) # Crash + sleep 1 + ;; + esac +done +exit ${ret}