From e37663cfc1b0026b458fa34ef099e507a7ee0cc8 Mon Sep 17 00:00:00 2001 From: mcguirepr89 Date: Wed, 9 Feb 2022 15:53:08 -0500 Subject: [PATCH] smarter advanced.php -- handles updating system with new settings instead of jsut files --- scripts/update_caddyfile.sh | 66 ++++++++++++++++++++++++++ scripts/update_settings_inprogress.php | 40 ++++++++++++++++ scripts/write_advanced.php | 60 ----------------------- 3 files changed, 106 insertions(+), 60 deletions(-) create mode 100755 scripts/update_caddyfile.sh create mode 100644 scripts/update_settings_inprogress.php delete mode 100644 scripts/write_advanced.php diff --git a/scripts/update_caddyfile.sh b/scripts/update_caddyfile.sh new file mode 100755 index 0000000..f2da502 --- /dev/null +++ b/scripts/update_caddyfile.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +source /etc/birdnet/birdnet.conf +set -x +[ -d /etc/caddy ] || mkdir /etc/caddy +if [ -f /etc/caddy/Caddyfile ];then + cp /etc/caddy/Caddyfile{,.original} +fi +if ! [ -z ${CADDY_PWD} ];then +HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD}) +cat << EOF > /etc/caddy/Caddyfile +http://localhost http://$(hostname).local ${BIRDNETPI_URL} { + root * ${EXTRACTED} + file_server browse + basicauth /Processed* { + birdnet ${HASHWORD} + } + basicauth /scripts* { + birdnet ${HASHWORD} + } + basicauth /stream { + birdnet ${HASHWORD} + } + basicauth /phpsysinfo* { + birdnet ${HASHWORD} + } + reverse_proxy /stream localhost:8000 + php_fastcgi unix//run/php/php7.4-fpm.sock +} +EOF +else + cat << EOF > /etc/caddy/Caddyfile +http://localhost http://$(hostname).local ${BIRDNETPI_URL} { + root * ${EXTRACTED} + file_server browse + reverse_proxy /stream localhost:8000 + php_fastcgi unix//run/php/php7.4-fpm.sock +} +EOF +fi + +if [ ! -z ${WEBTERMINAL_URL} ] && [ ! -z ${HASHWORD} ];then + cat << EOF >> /etc/caddy/Caddyfile +${WEBTERMINAL_URL} { + basicauth { + birdnet ${HASHWORD} + } + reverse_proxy localhost:8888 +} +EOF +elif [ ! -z ${WEBTERMINAL_URL} ] && [ -z ${HASHWORD} ];then + cat << EOF >> /etc/caddy/Caddyfile +${WEBTERMINAL_URL} { + reverse_proxy localhost:8888 +} +EOF +fi +if [ ! -z ${BIRDNETLOG_URL} ];then + cat << EOF >> /etc/caddy/Caddyfile + +${BIRDNETLOG_URL} { + reverse_proxy localhost:8080 +} +EOF +fi + +( systemctl reload caddy ) & diff --git a/scripts/update_settings_inprogress.php b/scripts/update_settings_inprogress.php new file mode 100644 index 0000000..0977e53 --- /dev/null +++ b/scripts/update_settings_inprogress.php @@ -0,0 +1,40 @@ + + + + + + + + +
+ + + + diff --git a/scripts/write_advanced.php b/scripts/write_advanced.php deleted file mode 100644 index fd13f39..0000000 --- a/scripts/write_advanced.php +++ /dev/null @@ -1,60 +0,0 @@ - -