diff --git a/SD_ROOT/wz_mini/etc/init.d/wz_user.sh b/SD_ROOT/wz_mini/etc/init.d/wz_user.sh index bb6a934..25025ec 100755 --- a/SD_ROOT/wz_mini/etc/init.d/wz_user.sh +++ b/SD_ROOT/wz_mini/etc/init.d/wz_user.sh @@ -593,6 +593,10 @@ if [[ "$NIGHT_DROP_DISABLE" == "true" ]]; then touch /opt/wz_mini/tmp/.nd fi +if [[ "$WEB_SERVER_ENABLED" == "true" ]]; then + httpd -p 80 -h /opt/wz_mini/www +fi + hostname_set touch /opt/wz_mini/tmp/.wz_user_firstrun pkill -f dumpload #Kill dumpload so it won't waste cpu or ram gathering cores and uploading them when something crashes diff --git a/SD_ROOT/wz_mini/etc/wz_mini.conf.dist b/SD_ROOT/wz_mini/etc/wz_mini.conf.dist index d1ca139..b7c3aa3 100644 --- a/SD_ROOT/wz_mini/etc/wz_mini.conf.dist +++ b/SD_ROOT/wz_mini/etc/wz_mini.conf.dist @@ -93,11 +93,15 @@ DISABLE_MOTOR="false" ENABLE_FSCK_ON_BOOT="false" ENABLE_CAR_DRIVER="false" +#####WEB##### +WEB_SERVER_ENABLED="false" + #####DEBUG##### #drops you to a shell via serial, doesn't load app_init.sh DEBUG_ENABLED="false" DEBUG_INITRAMFS_ENABLED="false" DEBUG_PASSWORD="false" + #####SCRIPTING##### CUSTOM_SCRIPT_PATH="" diff --git a/SD_ROOT/wz_mini/www/cgi-bin/DISABLE_FW_UPGRADE.md b/SD_ROOT/wz_mini/www/cgi-bin/DISABLE_FW_UPGRADE.md new file mode 100644 index 0000000..d5476fc --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/DISABLE_FW_UPGRADE.md @@ -0,0 +1,4 @@ +If a remote or app update is initiated, the camera will reboot due to the failure of the update. The firmware update should not proceed again for some time, or at all. + +When a firmware update is initiated, due to a bootloader issue (bug?), we intercept the update process and flash it manually. This should now result in a successful update, if it doesn't, please restore the unit's firmware manually using demo_wcv3.bin on the micro sd card. + diff --git a/SD_ROOT/wz_mini/www/cgi-bin/ENABLE_USB_ETH.md b/SD_ROOT/wz_mini/www/cgi-bin/ENABLE_USB_ETH.md new file mode 100644 index 0000000..fe75a63 --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/ENABLE_USB_ETH.md @@ -0,0 +1,13 @@ +USB Ethernet Adapter support: + +ENABLE_USB_ETH="true" +ENABLE_USB_ETH_MODULE_AUTODETECT="true" +ENABLE_USB_ETH_MODULE_MANUAL="" +To have the Ethernet NIC be auto-detected and loaded automatically, set the ENABLE_USB_ETH_MODULE_AUTODETECT value to true. + +To load a specific USB Ethernet NIC driver, set ENABLE_USB_ETH_MODULE_MANUAL to one of the following: asix, ax88179_178a, cdc_ether, r8152 + +NOTE: There is a possibility of a conflict between Ethernet NIC adapters that report themselves as PCI ID '0bda:8152'. (Realtek 8152 and CDC Ethernet) Since the 8152 is Realtek's product, that driver will be the one used for products that report that PCI ID. If you happen to have a CDC Ethernet product that uses that specific PCI ID, please set the ENABLE_USB_ETH_MODULE_AUTODETECT option to false, and set ENABLE_USB_ETH_MODULE_MANUAL to "cdc_ether" + +The next time you boot your camera, make sure your USB Ethernet Adapter is connected to the camera and ethernet. The camera has to be setup initially with Wi-Fi for this to work. After setup, Wi-Fi is no longer needed, as long as you are using the USB Ethernet Adapter. Note that using USB Ethernet disables the onboard Wi-Fi. + diff --git a/SD_ROOT/wz_mini/www/cgi-bin/ENABLE_WIREGUARD.md b/SD_ROOT/wz_mini/www/cgi-bin/ENABLE_WIREGUARD.md new file mode 100644 index 0000000..2f2fc67 --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/ENABLE_WIREGUARD.md @@ -0,0 +1,19 @@ +Wireguard support is available as a kernel module: + +ENABLE_WIREGUARD="true" +Use the command wg to setup. See https://www.wireguard.com/quickstart/ for more info. + +Some users have asked about tailscale support, I have tested and it works. See the issue #30 for further information. + +Example setup: + +ENABLE_WIREGUARD="true" +WIREGUARD_IPV4="192.168.2.101/32" +WIREGUARD_PEER_ENDPOINT="x.x.x.x:51820" +WIREGUARD_PEER_PUBLIC_KEY="INSERT_PEER_PUBLIC_KEY_HERE" +WIREGUARD_PEER_ALLOWED_IPS="192.168.2.0/24" +WIREGUARD_PEER_KEEP_ALIVE="25" +To retrieve the public key that you'll need to add the peer to your wireguard endpoint: + +Use SSH to log in +wg diff --git a/SD_ROOT/wz_mini/www/cgi-bin/index.cgi b/SD_ROOT/wz_mini/www/cgi-bin/index.cgi new file mode 100644 index 0000000..d390ad0 --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/index.cgi @@ -0,0 +1,157 @@ +#we!/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 "
$K=$VB
" + eval POST_$K=\"$VB\" + done + + + #switch back to going through the config file + IFS=$'\n' + output="$hack_ini.new" + + #name our output file + for ARGUMENT in $(cat $hack_ini) + do + #cycle through each line of the current config + + #copy through all comments + if [[ ${ARGUMENT:0:1} == "#" ]] ; then + #echo $ARGUMENT $'\n' + echo -ne $ARGUMENT"\n" >> $output + else + #for non-comments check to see if we have an entry in the POST data by deciphering the key from the ini file and using eval for our fake array + KEY=$(echo $ARGUMENT | cut -f1 -d=) + test=$(eval echo \$POST_$KEY) + #echo "key was $KEY test was ... $test
" + if [[ "$test" ]]; then + #if in the fake array then we use the new value + #echo "
matched
" + echo -ne $KEY=\"$test\""\n" >> $output + else + #if not in the fake array we use the current value + #echo "
key not found
" + echo -ne $ARGUMENT"\n" >> $output + fi + + fi + done + + shft $hack_ini + mv $output $hack_ini + echo "rebooting! wait a bit -- and go the same url" + reboot + exit +fi + + + +function documentation_to_html +{ + if [[ -f "$www_dir$1.md" ]]; then + printf '
'
+                cat $web_dir$1.md
+                printf '
' + fi +} + + +function ini_to_html_free +{ + printf '
%s
' $1 $1 $2 + documentation_to_html $1 + printf '
' +} + +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 '
' + documentation_to_html $1 + 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 '' diff --git a/SD_ROOT/wz_mini/www/cgi-bin/wz_mini_web.css b/SD_ROOT/wz_mini/www/cgi-bin/wz_mini_web.css new file mode 100644 index 0000000..046cff7 --- /dev/null +++ b/SD_ROOT/wz_mini/www/cgi-bin/wz_mini_web.css @@ -0,0 +1,26 @@ +.ii_info { + font-weight:bold; + background-color:#ccc; +} +.ii { + width:100%; + position:relative; + display:flex; +} +.ii_key_DIV { + + flex:0 0 30vw; + font-weight:bold; +} +.ii_value_DIV { + flex: 0 0 40vw; + text-align:right; +} +.ii_value { + width:75%; +} +.ii_explain { + width:29vw; + overflow:scroll; + max-height:140px; +} diff --git a/SD_ROOT/wz_mini/wz_mini.conf b/SD_ROOT/wz_mini/wz_mini.conf index d1ca139..0f95523 100644 --- a/SD_ROOT/wz_mini/wz_mini.conf +++ b/SD_ROOT/wz_mini/wz_mini.conf @@ -99,5 +99,8 @@ DEBUG_ENABLED="false" DEBUG_INITRAMFS_ENABLED="false" DEBUG_PASSWORD="false" +####WEB#### +WEB_SERVER_ENABLED="true" + #####SCRIPTING##### CUSTOM_SCRIPT_PATH=""