From 84e63535fd7cab422022259b8f761760958a276d Mon Sep 17 00:00:00 2001 From: virmaior <70625876+virmaior@users.noreply.github.com> Date: Sat, 17 Feb 2024 23:31:24 +0900 Subject: [PATCH] Update status.cgi - reduce `/configs` use and split TZ --- SD_ROOT/wz_mini/www/cgi-bin/status.cgi | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/SD_ROOT/wz_mini/www/cgi-bin/status.cgi b/SD_ROOT/wz_mini/www/cgi-bin/status.cgi index 98caa9d..c385516 100644 --- a/SD_ROOT/wz_mini/www/cgi-bin/status.cgi +++ b/SD_ROOT/wz_mini/www/cgi-bin/status.cgi @@ -1,11 +1,9 @@ #!/bin/sh -# This serves a rudimentary webpage to test different items +# This serves a rudimentary webpage to test different features of the camera . /opt/wz_mini/www/cgi-bin/shared.cgi -gpiopath="/sys/devices/virtual/gpio" -base='/opt/record/'; -TZ=$(cat /configs/TZ) +echo "tz: $TZ" test_gpio() { @@ -57,6 +55,7 @@ test_recording() { msg="" +utchour=$(TZ="UTC" date +"%H") fpath=$(TZ="$TZ" date +"%Y%m%d") nowmin=$(TZ="$TZ" date +"%M") curmin=$((10#$nowmin - 1)) @@ -64,6 +63,10 @@ curhour=$(TZ="$TZ" date +"%H") cursec=$(TZ="$TZ" date +"%S") +if [[ "$utchour" == "$curhour" ]]; then + echo "TZ is returning UTC (Possible parsing error?) $utcnow $tznow" +fi + if [[ "$cursec" -lt "03" ]]; then wt=$((3 - $cursec)) msg="delayed $wt seconds to allow copy to SD" @@ -83,32 +86,30 @@ fi curmin=$(printf %02d $curmin) -if [ ! -d "$base$fpath" ]; then +if [ ! -d "$recpath$fpath" ]; then echo -e "NG $lb" - echo "Date directory does not exist ($base$fname)" + echo "Date directory does not exist ($recpath$fpath)" + exit +fi + + +if [ ! -d "$recpath$fpath/$curhour" ]; then + echo -e "NG $lb" + echo "Hour directory does not exist ($recpath$fpath/$curhour)" exit fi - -if [ ! -d "$base$fpath/$curhour" ]; then +if [ ! -f "$recpath$fpath/$curhour/$curmin.mp4" ]; then echo -e "NG $lb" - echo "Hour directory does not exist ($base$fname/$curhour)" - exit -fi - - - -if [ ! -f "$base$fpath/$curhour/$curmin.mp4" ]; then - echo -e "NG $lb" - echo "Last minute not recorded ($base$fname/$curhour/$curmin.mp4)" + echo "Last minute not recorded ($recpath$fpath/$curhour/$curmin.mp4)" exit fi echo "OK$lb" -echo found "$base$fpath/$curhour/$curmin.mp4" +echo found "$recpath$fpath/$curhour/$curmin.mp4" echo $msg }