From c9f8235f482480de5f8c53e847ad8116627dc2a9 Mon Sep 17 00:00:00 2001
From: Paul Philippov <themactep@gmail.com>
Date: Fri, 1 Jul 2022 19:34:42 -0400
Subject: [PATCH] disable/enable httpd basic-auth after debug flag set in
 camera environment.

---
 general/package/microbe-web/files/S50httpd | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/general/package/microbe-web/files/S50httpd b/general/package/microbe-web/files/S50httpd
index 8494cee0..183e3883 100755
--- a/general/package/microbe-web/files/S50httpd
+++ b/general/package/microbe-web/files/S50httpd
@@ -2,12 +2,21 @@
 
 DAEMON="httpd"
 PIDFILE="/var/run/$DAEMON.pid"
+CONFFILE="/etc/httpd.conf"
 
-HTTPD_ARGS="httpd -p 85 -f -c /etc/httpd.conf -r Authentication"
+HTTPD_ARGS="httpd -p 85 -f -c $CONFFILE -r Authentication"
 
 # shellcheck source=/dev/null
 [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
 
+if [ "$(fw_printenv -n debug)" ]; then
+  echo "Development mode. Disabling Basic Auth"
+  sed -i "/^\/cgi-bin:admin:/s/^/#/" $CONFFILE
+else
+  echo "Production mode. Enabling Basic Auth"
+  sed -i "/^#\/cgi-bin:admin:/s/^#//" $CONFFILE
+fi
+
 # The httpd does not create a pidfile, so pass "-n" in the command line
 # and use "-m" to instruct start-stop-daemon to create one.
 start() {