#!/bin/sh # This serves a rudimentary webpage based on wz_mini.conf base_dir=/opt/wz_mini/ hack_ini=/opt/wz_mini/wz_mini.conf 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) hostname=$(uname -n) title="Wyze $camver on $camfirmware running wz_mini $hackver as $hostname" echo "HTTP/1.1 200" echo -e "Content-type: text/html\n\n" echo "" shft() { cd $base_dir # https://stackoverflow.com/questions/3690936/change-file-name-suffixes-using-sed/3691279#3691279 # Change this '8' to one less than your desired maximum rollover file. # Must be in reverse order for renames to work (n..1, not 1..n). for suff in {8..1} ; do if [[ -f "$1.${suff}" ]] ; then ((nxt = suff + 1)) mv -f "$1.${suff}" "$1.${nxt}" fi done mv -f "$1" "$1.1" } #test for post if [[ $REQUEST_METHOD = 'POST' ]]; then if [ "$CONTENT_LENGTH" -gt 0 ]; then read -n $CONTENT_LENGTH POST_DATA <&0 while read line do eval "echo ${line}" done fi #since ash does not handle arrays we create variables using eval IFS='&' for PAIR in $POST_DATA do K=$(echo $PAIR | cut -f1 -d=) VA=$(echo $PAIR | cut -f2 -d=) VB=\"${VA//%3A/:}\" #echo "
'
cat $web_dir$1.md
printf '