Shorten volume variable names
[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 sensors_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_sensor || true
16 }
17
18 sensors_fork_all() {
19 ./bin/khatus_x4_sensor_datetime &
20 ./bin/khatus_x4_sensor_bluetooth&
21 ./bin/khatus_x4_sensor_mpd &
22 ./bin/khatus_x4_sensor_energy &
23 }
24
25 sensor_read_one() {
26 if test -f "$1"
27 then
28 cat "$1"
29 else
30 printf '%s\n' '--'
31 fi
32 }
33
34 sensors_read_all() {
35 while :
36 do
37 battery_state="$(sensor_read_one ${dir}/khatus_x4_sensor_energy/out/battery_state)"
38 battery_percentage="$(sensor_read_one ${dir}/khatus_x4_sensor_energy/out/battery_percentage)"
39 bluetooth_controllers="$(sensor_read_one ${dir}/khatus_x4_sensor_bluetooth/out/count_powered_controllers)"
40 bluetooth_devices="$(sensor_read_one ${dir}/khatus_x4_sensor_bluetooth/out/count_connected_devices)"
41 datetime="$(sensor_read_one ${dir}/khatus_x4_sensor_datetime/out/datetime)"
42 mpd="$(sensor_read_one ${dir}/khatus_x4_sensor_mpd/out/status)"
43 echo "E[${battery_state} ${battery_percentage}] [${mpd}] [$bluetooth_controllers $bluetooth_devices] ${datetime}"
44 sleep 1
45 done
46 }
47
48 main() {
49 sensors_kill_all
50 sensors_fork_all
51 sensors_read_all
52 }
53
54 main
This page took 0.091976 seconds and 4 git commands to generate.