Last active
May 16, 2021 18:09
-
-
Save BETLOG/7f7c0bac55f25ad6c44b0f3c81dd232c to your computer and use it in GitHub Desktop.
/etc/rc.local - RPiCamWebInterface Annotation %a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: use /etc/rc.local to initiate a loop-script which writes to the RPiCamWebInterface Annotation (%a) file. | |
# | |
# servicectl services/timers may not run a 1 second timer at anyhting like 1 second intervals | |
# Whereas a script running a simple loop will. Particualrly if the loops timing accounts for minor variations. | |
# | |
# you can activate this either: | |
# 1) by manually adding the path/filename of the script to /etc/rc.local | |
# or | |
# 2) like I do: (as part of another script that loops through all of my pizerocams) | |
scp -q \ | |
/home/user/documents/scripts/raspberry/home/pi/piinfo.sh \ | |
$targetHost:/home/pi | |
msg1="activating:" ;msg2="user annotation %a"; f_msg | |
ssh -q $targetHost bash <<'EOF' | |
[[ -f /etc/rc.local && -z $(grep -o '/home/pi/piinfo.sh' /etc/rc.local) ]] && sudo sed -Ei 's/exit\ 0/\/home\/pi\/piinfo.sh \# services do not run evenly at actual second precision repeats so just fork a looping script\n\nexit\ 0/' /etc/rc.local | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# for use with RPiWebCamInterface %a | |
# initiate this script via /etc/rc.local | |
# or run it as root | |
# if you run it non-root values print to console but RPCWI will not use it as annotiation (%a) | |
# | |
while :; do # services do not run evenly at actual second precision repeats, so just fork a looping script | |
startTime=$(date +%s.%3N) | |
degC="$(echo "scale=1;$(cat /sys/class/thermal/thermal_zone0/temp)/1000"|bc|sed -E 's/^\./0\./')C" | |
annotation="$HOSTNAME ${degC}" | |
# last="$(cat /dev/shm/mjpeg/user_annotate.txt|sed -E 's/.*(.)/\1/')" | |
# [[ "<" == "$last" || "C" == "$last" ]] && annotation+=" >" || annotation+=" <" | |
echo -ne "$annotation" | |
[[ "$EUID" -eq 0 ]] && echo -ne "$annotation" >/dev/shm/mjpeg/user_annotate.txt | |
sleep $(echo "scale=3; 1.000 - ( $(date +%s.%3N) - $startTime )"|bc)s | |
done |
sudo apt install bc
Working, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo apt install bc