Fix Grafana Kiosk to use killall
Fbi seems to fork and continue on another process, as the shown process ID does not match the returned value. Use killall to fix this problem. Note that this only works because nobody else is using fbi on the system.
This commit is contained in:
parent
bb013fe97e
commit
592d864283
1 changed files with 7 additions and 11 deletions
18
templates/hobbes/kiosk.sh.j2
Executable file → Normal file
18
templates/hobbes/kiosk.sh.j2
Executable file → Normal file
|
@ -16,10 +16,11 @@ fbi_pid=0
|
||||||
# Function to be executed on SIGTERM
|
# Function to be executed on SIGTERM
|
||||||
on_sigterm() {
|
on_sigterm() {
|
||||||
echo "SIGTERM received, exiting..."
|
echo "SIGTERM received, exiting..."
|
||||||
# Kill the fbi process with the stored PID
|
|
||||||
if [ $fbi_pid -ne 0 ]; then
|
# Kill the fbi process
|
||||||
sudo kill $fbi_pid
|
# As the process forks itself, we do not get a reliable PID and killall is needed
|
||||||
fi
|
killall fbi
|
||||||
|
|
||||||
# Remove the temporary file
|
# Remove the temporary file
|
||||||
rm -f /tmp/grafana.png
|
rm -f /tmp/grafana.png
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -34,13 +35,8 @@ do
|
||||||
mosquitto_sub -h $BROKER -t $TOPIC -C 1 > /tmp/grafana.png
|
mosquitto_sub -h $BROKER -t $TOPIC -C 1 > /tmp/grafana.png
|
||||||
|
|
||||||
# Kill the previous fbi process
|
# Kill the previous fbi process
|
||||||
if [ $fbi_pid -ne 0 ]; then
|
# As the process forks itself, we do not get a reliable PID and killall is needed
|
||||||
sudo kill $fbi_pid
|
killall fbi
|
||||||
fi
|
|
||||||
|
|
||||||
# Display the image using fbi
|
|
||||||
fbi -T 1 -noverbose -a /tmp/grafana.png &
|
|
||||||
fbi_pid=$!
|
|
||||||
|
|
||||||
# Wait to avoid a race condition between
|
# Wait to avoid a race condition between
|
||||||
# fbi starting and mosquitto truncating the file
|
# fbi starting and mosquitto truncating the file
|
||||||
|
|
Loading…
Reference in a new issue