diff --git a/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh new file mode 100644 index 0000000..86db43e --- /dev/null +++ b/SD_ROOT/wz_mini/web/cgi-bin/wz_mini_web.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# This serves a rudimentary webpage based on wz_mini.conf +hack_ini=/opt/wz_mini/wz_mini.conf +camver=V3 +camfirmware=$(tail -n1 /configs/app.ver | cut -f2 -d= ) +hackver="unknown" +hostname=$(uname -n) +title="Wyze $camver on $camfirmware running wz_mini $hackver as $hostname" + + +echo "HTTP/1.1 200" +echo "" +#echo "Content Length: 100000" + +function ini_to_html_free +{ + printf '
%s
' $1 $1 $2 +} + +function ini_to_html_tf +{ + printf '
%s
' $1 + printf '
' + if [[ "$2" == "true" ]]; then + printf ' True  ' $1 + printf ' False  ' $1 + else + printf ' True  ' $1 + printf ' False  ' $1 + + fi + printf '
' +} + + +echo -ne "$title" +echo -ne "'; +echo -ne "" +echo -ne '' +echo -ne "

$title

"; +echo -ne '
' + +IFS=$'\n' +for ARGUMENT in $(cat $hack_ini) +do + if [[ ${ARGUMENT:0:1} == "#" ]] ; then + echo -ne '
'$ARGUMENT'
' + else + KEY=$(echo $ARGUMENT | cut -f1 -d=) + VAL=$(echo $ARGUMENT | cut -f2 -d=) + VALUE=${VAL//\"/} + case "$VALUE" in + "true") ini_to_html_tf $KEY $VALUE ;; + "false") ini_to_html_tf $KEY $VALUE ;; + *) ini_to_html_free $KEY $VALUE + esac + fi +done + +echo -ne '' +echo -ne '
' +echo -ne ''