From 91e76ec9449deab39590272be644fc17e9f0420f Mon Sep 17 00:00:00 2001 From: virmaior <70625876+virmaior@users.noreply.github.com> Date: Wed, 10 Aug 2022 10:26:14 +0900 Subject: [PATCH] fixes to www (#231) fixed display of camera version, fixed issue jpeg.cgi, added diagnostics page, minor css improvements, made shared.cgi for common code between diagnostics and config --- SD_ROOT/wz_mini/www/cgi-bin/config.cgi | 25 ++------ SD_ROOT/wz_mini/www/cgi-bin/config.css | 10 ++-- SD_ROOT/wz_mini/www/cgi-bin/diagnostics.cgi | 64 +++++++++++++++++++++ SD_ROOT/wz_mini/www/cgi-bin/jpeg.cgi | 1 - SD_ROOT/wz_mini/www/cgi-bin/shared.cgi | 33 +++++++++++ SD_ROOT/wz_mini/www/index.html | 2 +- 6 files changed, 110 insertions(+), 25 deletions(-) create mode 100644 SD_ROOT/wz_mini/www/cgi-bin/diagnostics.cgi create mode 100644 SD_ROOT/wz_mini/www/cgi-bin/shared.cgi diff --git a/SD_ROOT/wz_mini/www/cgi-bin/config.cgi b/SD_ROOT/wz_mini/www/cgi-bin/config.cgi index 260be33..a73a6ed 100644 --- a/SD_ROOT/wz_mini/www/cgi-bin/config.cgi +++ b/SD_ROOT/wz_mini/www/cgi-bin/config.cgi @@ -1,15 +1,13 @@ #!/bin/sh # This serves a rudimentary webpage based on wz_mini.conf -base_dir=/opt/wz_mini/ -base_hack_ini=/opt/wz_mini/wz_mini.conf -hack_ini=$base_hack_ini -www_dir=/opt/wz_mini/www/cgi-bin/ -camver=V3 -camfirmware=$(tail -n1 /configs/app.ver | cut -f2 -d= ) -hackver=$(cat /opt/wz_mini/usr/bin/app.ver) -title="Wyze $camver on $camfirmware running wz_mini $hackver as $HOSTNAME" +. /opt/wz_mini/www/cgi-bin/shared.cgi + +title="$camver on $camfirmware running wz_mini $hackver as $HOSTNAME" updated=false + + + echo "HTTP/1.1 200" echo -e "Content-type: text/html\n\n" echo "" @@ -65,17 +63,6 @@ function revert_menu echo '' } -function version_info -{ - echo "
" - echo "
$camver
" - echo "
$camfirmware
" - echo "
$hackver
" - echo "
$HOSTNAME
" - echo "
" -} - - if [[ $REQUEST_METHOD = 'GET' ]]; then diff --git a/SD_ROOT/wz_mini/www/cgi-bin/config.css b/SD_ROOT/wz_mini/www/cgi-bin/config.css index 29a7e98..5f8d8b3 100644 --- a/SD_ROOT/wz_mini/www/cgi-bin/config.css +++ b/SD_ROOT/wz_mini/www/cgi-bin/config.css @@ -127,10 +127,12 @@ H1 { padding-right:15px; } .ver_DIV { - padding-left:60px; - min-width:120px; - font-family:monospace; - flex: 1 0 120px; + padding-left: 2vw; + min-width: 12vw; + font-family: monospace; + flex: 1 0 9vw; + overflow: hidden; + font-size: 1.1vw; } .ver_DIV:before { content:attr(vertype); diff --git a/SD_ROOT/wz_mini/www/cgi-bin/diagnostics.cgi b/SD_ROOT/wz_mini/www/cgi-bin/diagnostics.cgi new file mode 100644 index 0000000..c9651b1 --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/diagnostics.cgi @@ -0,0 +1,64 @@ +#!/bin/sh +# diagnostics + +. /opt/wz_mini/www/cgi-bin/shared.cgi +title="Diagnostics $camver on $camfirmware running wz_mini $hackver as $HOSTNAME" + + +function handle_css +{ +echo -ne "'; +} + + +dmesg_test() +{ +x=$(dmesg | grep $1) +if [-n "$x" ]; then + echo "
$2 error found
" +else + echo "
no $2 error
" +fi + +} + +echo "HTTP/1.1 200" +echo -e "Content-type: text/html\n\n" +echo "" + +echo "$title" +handle_css +echo "" + +echo "" + +echo "

$title

" + + +echo "

SD Card Test

" + +dmesg_test "invalid access to FAT" "SD card" +dmesg_test "Filesystem has been set read-only" "SD read only" +dmesg_test "fat_get_cluster: invalid cluster chain" "file system" + + +echo "

Firmware Version Test

" + +echo "Firmware Version: $camfirmware
" + +if [ "$camfirmware" = "4.36.10.2163" ]; then + echo "
this version is broken. Please downgrade to a working version
" +fi + + +echo "
"
+dmesg
+echo "
" + + +version_info "display_BAR" +echo "" + +echo "" diff --git a/SD_ROOT/wz_mini/www/cgi-bin/jpeg.cgi b/SD_ROOT/wz_mini/www/cgi-bin/jpeg.cgi index 3b6efe8..97246fc 100644 --- a/SD_ROOT/wz_mini/www/cgi-bin/jpeg.cgi +++ b/SD_ROOT/wz_mini/www/cgi-bin/jpeg.cgi @@ -4,7 +4,6 @@ #test for jpeg if [[ $REQUEST_METHOD = 'GET' ]]; then - echo "entered GET" #since ash does not handle arrays we create variables using eval IFS='&' for PAIR in $QUERY_STRING diff --git a/SD_ROOT/wz_mini/www/cgi-bin/shared.cgi b/SD_ROOT/wz_mini/www/cgi-bin/shared.cgi new file mode 100644 index 0000000..8850cee --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/shared.cgi @@ -0,0 +1,33 @@ +#!/bin/sh +# This provides shared values for webpages +base_dir=/opt/wz_mini/ +base_hack_ini=/opt/wz_mini/wz_mini.conf +hack_ini=$base_hack_ini +www_dir=/opt/wz_mini/www/cgi-bin/ +camver=V3 + +if [ -f /opt/wz_mini/tmp/.T31 ]; then +camtype=T31 +elif [ -f /opt/wz_mini/tmp/.T20 ]; then +camtype=T20 +fi + +cammodel=$(/opt/wz_mini/etc/init.d/s04model start | grep detected | cut -f1 -d ' ' ) + +camver="$camtype($cammodel)" + +camfirmware=$(tail -n1 /configs/app.ver | cut -f2 -d= ) +hackver=$(cat /opt/wz_mini/usr/bin/app.ver) + + +function version_info +{ + echo "
" + echo "
$camver
" + echo "
$camfirmware
" + echo "
$hackver
" + echo "
$HOSTNAME
" + echo "
" +} + + diff --git a/SD_ROOT/wz_mini/www/index.html b/SD_ROOT/wz_mini/www/index.html index 81f894b..063759e 100644 --- a/SD_ROOT/wz_mini/www/index.html +++ b/SD_ROOT/wz_mini/www/index.html @@ -5,6 +5,6 @@

Configuration Editor

Car Interface

Current Screen

- +

Diagnostics