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
This commit is contained in:
virmaior 2022-08-10 10:26:14 +09:00 committed by GitHub
parent e7ccea5454
commit 91e76ec944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 110 additions and 25 deletions

View File

@ -1,15 +1,13 @@
#!/bin/sh #!/bin/sh
# This serves a rudimentary webpage based on wz_mini.conf # This serves a rudimentary webpage based on wz_mini.conf
base_dir=/opt/wz_mini/ . /opt/wz_mini/www/cgi-bin/shared.cgi
base_hack_ini=/opt/wz_mini/wz_mini.conf
hack_ini=$base_hack_ini title="$camver on $camfirmware running wz_mini $hackver as $HOSTNAME"
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"
updated=false updated=false
echo "HTTP/1.1 200" echo "HTTP/1.1 200"
echo -e "Content-type: text/html\n\n" echo -e "Content-type: text/html\n\n"
echo "" echo ""
@ -65,17 +63,6 @@ function revert_menu
echo '</div>' echo '</div>'
} }
function version_info
{
echo "<div id='$1'>"
echo "<div class='ver_DIV' vertype='Camera'>$camver</div>"
echo "<div class='ver_DIV' vertype='Camera Firmware'>$camfirmware</div>"
echo "<div class='ver_DIV' vertype='wz_mini'>$hackver</div>"
echo "<div class='ver_DIV' vertype='Hostname'> $HOSTNAME</div>"
echo "</div>"
}
if [[ $REQUEST_METHOD = 'GET' ]]; then if [[ $REQUEST_METHOD = 'GET' ]]; then

View File

@ -127,10 +127,12 @@ H1 {
padding-right:15px; padding-right:15px;
} }
.ver_DIV { .ver_DIV {
padding-left:60px; padding-left: 2vw;
min-width:120px; min-width: 12vw;
font-family:monospace; font-family: monospace;
flex: 1 0 120px; flex: 1 0 9vw;
overflow: hidden;
font-size: 1.1vw;
} }
.ver_DIV:before { .ver_DIV:before {
content:attr(vertype); content:attr(vertype);

View File

@ -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 "<style type=\"text/css\">"
cat config.css
echo -ne '</style>';
}
dmesg_test()
{
x=$(dmesg | grep $1)
if [-n "$x" ]; then
echo "<div>$2 error found</div>"
else
echo "<div>no $2 error</div>"
fi
}
echo "HTTP/1.1 200"
echo -e "Content-type: text/html\n\n"
echo ""
echo "<html><head><title>$title</title>"
handle_css
echo "</head>"
echo "<body>"
echo "<h1>$title</h1>"
echo "<h2>SD Card Test</h2>"
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 "<h2>Firmware Version Test</h2>"
echo "Firmware Version: $camfirmware <br />"
if [ "$camfirmware" = "4.36.10.2163" ]; then
echo "<div>this version is broken. Please downgrade to a working version</div>"
fi
echo "<pre>"
dmesg
echo "</pre>"
version_info "display_BAR"
echo "</body>"
echo "</html>"

View File

@ -4,7 +4,6 @@
#test for jpeg #test for jpeg
if [[ $REQUEST_METHOD = 'GET' ]]; then if [[ $REQUEST_METHOD = 'GET' ]]; then
echo "entered GET"
#since ash does not handle arrays we create variables using eval #since ash does not handle arrays we create variables using eval
IFS='&' IFS='&'
for PAIR in $QUERY_STRING for PAIR in $QUERY_STRING

View File

@ -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 "<div id='$1'>"
echo "<div class='ver_DIV' vertype='Model'>$camver</div>"
echo "<div class='ver_DIV' vertype='Firmware'>$camfirmware</div>"
echo "<div class='ver_DIV' vertype='wz_mini'>$hackver</div>"
echo "<div class='ver_DIV' vertype='Hostname'> $HOSTNAME</div>"
echo "</div>"
}

View File

@ -5,6 +5,6 @@
<p><a href="cgi-bin/config.cgi">Configuration Editor</a></p> <p><a href="cgi-bin/config.cgi">Configuration Editor</a></p>
<p><a href="car/car.html">Car Interface</a></p> <p><a href="car/car.html">Car Interface</a></p>
<p><a href="cgi-bin/jpeg.cgi">Current Screen</a></p> <p><a href="cgi-bin/jpeg.cgi">Current Screen</a></p>
<p><a href="cgi-bin/diagnostics.cgi">Diagnostics</a></p>
</body> </body>
</html> </html>