mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-09 23:18:20 +00:00
Add Basic Auth to Web Server portal (#391)
Add Basic Auth to Web Server portal
This commit is contained in:
parent
725e52609e
commit
f004af3ef5
@ -525,9 +525,14 @@ Enables `dnsmasq`, a lightweight, local, caching DNS server on the camera. Fixe
|
||||
### Web Server:
|
||||
```
|
||||
WEB_SERVER_ENABLED="true"
|
||||
WEB_SERVER_AUTH="true"
|
||||
WEB_SERVER_LOGIN="admin"
|
||||
WEB_SERVER_PASSWORD=""
|
||||
```
|
||||
|
||||
Enables the local webserver, for configuration, car control, or to retreive an image snapshot via a web browser. Available at : `http://<Camera IP>/` Thank you @virmaior!
|
||||
Similar to the RTSP default password, if you don't set the password, the password will be set to the unique MAC address of the camera, in all uppercase, including the colons.
|
||||
If you do not want to have an authentication prompt for the local webserver, set WEB_SERVER_AUTH to false.
|
||||
|
||||
```
|
||||
WEB_SERVER_OPTIONS="cam config car jpeg"`
|
||||
|
@ -7,26 +7,69 @@
|
||||
|
||||
. /opt/wz_mini/wz_mini.conf
|
||||
|
||||
create_httpdconf()
|
||||
{
|
||||
conffile="/opt/wz_mini/etc/httpd.conf"
|
||||
if [[ -f $conffile ]]; then
|
||||
rm $conffile
|
||||
fi
|
||||
|
||||
if [[ "$WEB_SERVER_PASSWORD" == "" ]]; then
|
||||
WEB_SERVER_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
|
||||
fi
|
||||
|
||||
webpassword=$(busybox httpd -m "$WEB_SERVER_PASSWORD")
|
||||
|
||||
authline="/:$WEB_SERVER_LOGIN:$webpassword"
|
||||
|
||||
cat <<EOF > $conffile
|
||||
$authline
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
do_start()
|
||||
{
|
||||
create_httpdconf
|
||||
if [[ "$WEB_SERVER_AUTH" == "false" ]]; then
|
||||
httpd -p 80 -h /opt/wz_mini/www
|
||||
echo "httpd enabled"
|
||||
elif [[ "$WEB_SERVER_AUTH" == "true" ]]; then
|
||||
httpd -p 80 -h /opt/wz_mini/www -r "Identify yourself:" -c /opt/wz_mini/etc/httpd.conf
|
||||
echo "httpd enabled"
|
||||
fi
|
||||
}
|
||||
do_stop()
|
||||
{
|
||||
|
||||
#pkill httpd
|
||||
pidnum=$(ps | egrep "[0-9]{2} httpd -p 80" | awk '{print $1}')
|
||||
if [[ -z $pidnum ]]; then
|
||||
echo "httpd was not running"
|
||||
else
|
||||
kill $pidnum
|
||||
echo "httpd killed"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
if [[ "$WEB_SERVER_ENABLED" == "true" ]]; then
|
||||
case "$1" in
|
||||
start)
|
||||
|
||||
echo "#####$(basename "$0")#####"
|
||||
|
||||
if [[ "$WEB_SERVER_ENABLED" == "true" ]]; then
|
||||
httpd -p 80 -h /opt/wz_mini/www
|
||||
echo "httpd enabled"
|
||||
fi
|
||||
do_start
|
||||
;;
|
||||
stop)
|
||||
pkill dnsmasq
|
||||
do_stop
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
do_stop
|
||||
do_start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop}"
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
@ -109,6 +109,9 @@ ENABLE_SYSLOG_SAVE="false"
|
||||
|
||||
####WEB####
|
||||
WEB_SERVER_ENABLED="false"
|
||||
WEB_SERVER_AUTH="true"
|
||||
WEB_SERVER_LOGIN="admin"
|
||||
WEB_SERVER_PASSWORD=""
|
||||
|
||||
#####SCRIPTING#####
|
||||
CUSTOM_SCRIPT_PATH=""
|
||||
|
Loading…
Reference in New Issue
Block a user