Run sanity_check sensors as children and pre-kill all existing
[khatus.git] / x4 / sanity_check
1 #! /bin/sh
2
3 set -e
4
5 . ./bin/khatus_x4_lib_common_sensor.sh
6
7 dir="${prefix}/${host}"
8
9 kill_all() {
10 for pid_file in $(find $dir -type f -name pid)
11 do
12 kill -9 $(cat $pid_file) || true
13 rm $pid_file
14 done
15 pkill khatus_x4
16 }
17
18 read_sensor() {
19 if test -f "$1"
20 then
21 cat "$1"
22 else
23 printf '%s\n' '--'
24 fi
25 }
26
27 kill_all
28
29 ./bin/khatus_x4_sensor_datetime &
30 ./bin/khatus_x4_sensor_mpd &
31 ./bin/khatus_x4_sensor_energy &
32
33 while :
34 do
35 battery_state="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_state)"
36 battery_percentage="$(read_sensor ${dir}/khatus_x4_sensor_energy/out/battery_percentage)"
37 datetime="$(read_sensor ${dir}/khatus_x4_sensor_datetime/out/datetime)"
38 mpd="$(read_sensor ${dir}/khatus_x4_sensor_mpd/out/status)"
39 echo "E[${battery_state} ${battery_percentage}] [${mpd}] ${datetime}"
40 sleep 1
41 done
This page took 0.047494 seconds and 4 git commands to generate.