adding features to birdnet-pi-config
can now adjust/set/reset the following: - sensitivity - overlap - minimum confidence score - custom BirdNET-Pi URLs - CADDY_PWD - Database Passwords - Lat and Lon
This commit is contained in:
+208
-2
@@ -473,6 +473,135 @@ do_wifi_ssid_passphrase() {
|
||||
return $RET
|
||||
}
|
||||
|
||||
do_reget_birdnetlog_url() {
|
||||
birdnetlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetlog.pmcgui.xyz\"." \
|
||||
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_extractionlog_url() {
|
||||
extractionlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://extractionlog.pmcgui.xyz\"." \
|
||||
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_birdnetpi_url() {
|
||||
birdnetpi_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetpi.pmcgui.xyz\"." \
|
||||
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_db_root_pwd() {
|
||||
db_root_pwd=$(whiptail --inputbox "Please set the password the 'root' user will use to access the database." \
|
||||
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_db_pwd() {
|
||||
db_pwd=$(whiptail --inputbox "Please set the password the 'birder' user will use to access the database." \
|
||||
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_caddy_pwd() {
|
||||
caddy_pwd=$(whiptail --inputbox "Please set the password for the web interface." \
|
||||
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
do_reget_lon() {
|
||||
lon="$(curl -s4 ifconfig.co/json | awk '/lon/ {print $2}' | tr -d ',')"
|
||||
new_lon=$(whiptail --inputbox "Please set the longitude where recordings will take place." \
|
||||
19 70 -- "$lon" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_lat() {
|
||||
lat="$(curl -s4 ifconfig.co/json | awk '/lat/ {print $2}' | tr -d ',')"
|
||||
new_lat=$(whiptail --inputbox "Please set the latitude where recordings will take place." \
|
||||
19 70 -- "$lat" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_get_confidence() {
|
||||
confidence="$(awk -F= '/CONFIDENCE=/ {print $2}' ${birdnetpi_dir}/birdnet.conf)"
|
||||
new_confidence=$(whiptail --inputbox "Please set the minimum confidence score BirdNET-Lite should use." \
|
||||
19 70 -- "$confidence" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
do_get_overlap() {
|
||||
overlap="$(awk -F= '/OVERLAP=/ {print $2}' ${birdnetpi_dir}/birdnet.conf)"
|
||||
new_overlap=$(whiptail --inputbox "Please set the overlap BirdNET-Lite should use." \
|
||||
19 70 -- "$overlap" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
do_get_sensitivity() {
|
||||
sensitivity="$(awk -F= '/SENSITIVITY=/ {print $2}' ${birdnetpi_dir}/birdnet.conf)"
|
||||
new_sensitivity=$(whiptail --inputbox "Please set the simoid sensitivty BirdNET-Lite should use." \
|
||||
19 70 -- "$sensitivity" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
|
||||
if [ $? -eq 0 ];then
|
||||
return 0
|
||||
ASK_TO_REBOOT=2
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_get_birdnetlog_url() {
|
||||
birdnetlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetlog.pmcgui.xyz\"." \
|
||||
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
|
||||
@@ -672,6 +801,31 @@ do_system_menu() {
|
||||
fi
|
||||
}
|
||||
|
||||
do_advanced_reconfig_menu() {
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
"Sensitivity" "Set the sigmoid sensitivity" \
|
||||
"Confidence" "Set the minimum confidence score required for a detection" \
|
||||
"Overlap" "Set the analysis overlap in seconds" \
|
||||
"BirdNET-Pi URLs" "Set the URLs your installation should use" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
exit
|
||||
fi
|
||||
RET=$?
|
||||
if [ $RET -eq 1 ]; then
|
||||
return 0
|
||||
elif [ $RET -eq 0 ]; then
|
||||
case "$FUN" in
|
||||
Sens*) do_get_sensitivity;;
|
||||
Confi*) do_get_confidence;;
|
||||
Overlap*) do_get_overlap;;
|
||||
Bird*) do_reget_birdnetpi_url; do_reget_birdnetlog_url; do_reget_extractionlog_url;;
|
||||
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
|
||||
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
fi
|
||||
}
|
||||
|
||||
do_advanced_config_menu() {
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
@@ -697,6 +851,28 @@ do_advanced_config_menu() {
|
||||
fi
|
||||
}
|
||||
|
||||
do_reget_db_pwds() {
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Reset Datbase Passwords" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
"'birder' " "Set the database password for the 'birder' user" \
|
||||
"'root' " "Set the database password for the 'root' user" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
exit
|
||||
fi
|
||||
RET=$?
|
||||
if [ $RET -eq 1 ]; then
|
||||
return 0
|
||||
elif [ $RET -eq 0 ]; then
|
||||
case "$FUN" in
|
||||
*bird*) do_reget_db_pwd;;
|
||||
*root*) do_reget_db_root_pwd;;
|
||||
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
|
||||
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
do_get_db_pwds() {
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Set Datbase Passwords" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
@@ -718,6 +894,34 @@ do_get_db_pwds() {
|
||||
fi
|
||||
}
|
||||
|
||||
do_reconfig_birdnet_menu() {
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Re-configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
"Latitude " "Set the latitude your system should use" \
|
||||
"Longitude" "Set the longitude your system should use" \
|
||||
"Caddy Password" "Set the web interface password" \
|
||||
"Database Passwords" "Set the passwords the MariaDB will use" \
|
||||
"Advanced Settings" "Sensitivity, Overlap, Confidence, URLs" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
exit
|
||||
fi
|
||||
RET=$?
|
||||
if [ $RET -eq 1 ]; then
|
||||
return 0
|
||||
elif [ $RET -eq 0 ]; then
|
||||
case "$FUN" in
|
||||
Lat*) do_reget_lat;;
|
||||
Lon*) do_reget_lon;;
|
||||
Cad*) do_reget_caddy_pwd;;
|
||||
Data*) do_reget_db_pwds;;
|
||||
Advanced*) do_advanced_reconfig_menu;;
|
||||
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
|
||||
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
do_config_birdnet_menu() {
|
||||
if is_pi ; then
|
||||
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
|
||||
@@ -726,7 +930,7 @@ do_config_birdnet_menu() {
|
||||
"Caddy Password" "Set the web interface password" \
|
||||
"IceCast2 Password" "Set the IceCast2 password" \
|
||||
"Database Passwords" "Set the passwords the MariaDB will use" \
|
||||
"Advanced Settings" "Sensitivity, Overlap, Confidence, URLs" \
|
||||
"Set Custom URLS" "Designate custom URLs for the web services if you've set that up" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
exit
|
||||
@@ -741,7 +945,7 @@ do_config_birdnet_menu() {
|
||||
Cad*) do_get_caddy_pwd;;
|
||||
Ice*) do_get_ice_pwd;;
|
||||
Data*) do_get_db_pwds;;
|
||||
Advanced*) do_advanced_config_menu;;
|
||||
Set*) do_get_birdnetpi_url; do_get_birdnetlog_url; do_get_extractionlog_url;;
|
||||
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
|
||||
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
fi
|
||||
@@ -799,6 +1003,7 @@ if [ "$INTERACTIVE" = True ]; then
|
||||
"Step 1" "Configure language" \
|
||||
"Step 2" "Configure BirdNET-Pi before installation" \
|
||||
"Step 3" "Install BirdNET-Pi" \
|
||||
"Reconfigure BirdNET-Pi" "Reconfigure BirdNET-Pi AFTER installation" \
|
||||
"System Options" "Configure system settings" \
|
||||
3>&1 1>&2 2>&3)
|
||||
else
|
||||
@@ -812,6 +1017,7 @@ if [ "$INTERACTIVE" = True ]; then
|
||||
*1) do_internationalisation_menu ;;
|
||||
*2) do_config_birdnet_menu ;;
|
||||
*3) do_install_birdnet;;
|
||||
Reconf*) do_reconfig_birdnet_menu ;;
|
||||
Sys*) do_system_menu ;;
|
||||
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
|
||||
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/bash
|
||||
# Writes variables to config file
|
||||
set -x
|
||||
birdnetpi_dir=/home/pi/BirdNET-Pi
|
||||
birdnet_conf=${birdnetpi_dir}/birdnet.conf
|
||||
|
||||
if ! [ -z ${new_lat} ];then
|
||||
sed -i s/'^LATITUDE=.*'/"LATITUDE=${new_lat}"/g ${birdnet_conf}
|
||||
fi
|
||||
|
||||
if ! [ -z ${new_lon} ];then
|
||||
sed -i s/'^LONGITUDE=.*'/"LONGITUDE=${new_lon}"/g ${birdnet_conf}
|
||||
fi
|
||||
|
||||
if ! [ -z ${caddy_pwd} ];then
|
||||
sed -i s/'^CADDY_PWD=.*'/"CADDY_PWD=${caddy_pwd}"/g ${birdnet_conf}
|
||||
hash_pwd=$(caddy hash-password -plaintext ${caddy_pwd})
|
||||
sed -i s/'birdnet\ .*'/"birdnet ${hash_pwd}"/g /etc/caddy/Caddyfile
|
||||
systemctl reload caddy
|
||||
fi
|
||||
|
||||
if ! [ -z ${db_pwd} ];then
|
||||
sed -i s/'^DB_PWD=.*'/"DB_PWD=${db_pwd}"/g ${birdnet_conf}
|
||||
sudo -upi ${birdnetpi_dir}/scripts/update_db_pwd.sh
|
||||
fi
|
||||
|
||||
if ! [ -z ${db_root_pwd} ];then
|
||||
exit 1 #for now
|
||||
sed -i s/'^DB_ROOT_PWD=.*'/"DB_ROOT_PWD=${db_root_pwd}"/g ${birdnet_conf}
|
||||
fi
|
||||
|
||||
if ! [ -z ${birdnetpi_url} ];then
|
||||
sed -i s/'^BIRDNETPI_URL=.*'/"BIRDNETPI_URL=${birdnetpi_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
|
||||
sed -i s/'^EXTRACTIONLOG_URL=.*'/"EXTRACTIONLOG_URL=${extractionlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
|
||||
sed -i s/'^BIRDNETLOG_URL=.*'/"BIRDNETLOG_URL=${birdnetlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
|
||||
sudo -upi ${birdnetpi_dir}/scripts/update_birdnetpi.sh
|
||||
fi
|
||||
|
||||
if ! [ -z ${new_sensitivity} ];then
|
||||
sed -i s/'^SENSITIVITY=.*'/"SENSITIVITY=${new_sensitivity}"/g ${birdnet_conf}
|
||||
fi
|
||||
|
||||
if ! [ -z ${new_confidence} ];then
|
||||
sed -i s/'^CONFIDENCE=.*'/"CONFIDENCE=${new_confidence}"/g ${birdnet_conf}
|
||||
fi
|
||||
Reference in New Issue
Block a user