more sophisticated birdnet-pi-config

-- adjusted per notes from @CaiusX
This commit is contained in:
Patrick McGuire
2021-11-03 13:53:17 -04:00
parent 338ee05585
commit 9e9d234431
2 changed files with 285 additions and 267 deletions
+159 -140
View File
@@ -687,6 +687,10 @@ do_update_os() {
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
} }
do_update_birdnet() {
sudo -E -upi ${birdnetpi_dir}/scripts/update_birdnet.sh
}
do_install_birdnet() { do_install_birdnet() {
sudo -E -upi ${birdnetpi_dir}/Birders_Guide_Installer.sh && \ sudo -E -upi ${birdnetpi_dir}/Birders_Guide_Installer.sh && \
ASK_TO_REBOOT=1 ASK_TO_REBOOT=1
@@ -725,26 +729,142 @@ if [ $(id -u) -ne 0 ]; then
exit 1 exit 1
fi fi
do_get_urls_menu() { do_advanced_reconfig_menu() {
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Interfacing Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \ MENU=9
"BirdNET-Pi URL" "Set the main web interface URL" \ while [ $MENU -eq 9 ];do
"BirdNET Analysis Log URL" "Set the URL that will be used to view the BirdNET log" \ if is_pi ; then
"Audio Extraction Log URL" "Set the URL that will be used to view the Audio Extraction log" \ 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) 3>&1 1>&2 2>&3)
else
exit
fi
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
return 0 return 0
MENU=0
elif [ $RET -eq 0 ]; then elif [ $RET -eq 0 ]; then
case "$FUN" in case "$FUN" in
*Pi*) do_get_birdnetpi_url;; Sens*) do_get_sensitivity;;
*Analysis*) do_get_extractionlog_url;; Confi*) do_get_confidence;;
Audio*) do_get_birdnetlog_url;; Overlap*) do_get_overlap;;
Bird*) do_reget_birdnetpi_urls;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi fi
done
}
do_reget_db_pwds() {
MENU=8
while [ $MENU -eq 8 ];do
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
MENU=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
done
}
do_get_db_pwds() {
MENU=7
while [ $MENU -eq 7 ];do
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 \
"'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
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
*bird*) do_get_db_pwd;;
*root*) do_get_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
done
}
do_interface_menu() {
MENU=6
while [ $MENU -eq 6 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Interfacing Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"SSH" "Enable/disable remote command line access using SSH" \
"VNC" "Enable/disable graphical remote access using RealVNC" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
SSH*) do_ssh ;;
VNC*) do_vnc ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_advanced_config_menu() {
MENU=5
while [ $MENU -eq 5 ];do
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
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Sens*) do_get_sensitivity;;
Confi*) do_get_confidence;;
Overlap*) do_get_overlap;;
Bird*) 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
done
} }
do_system_menu() { do_system_menu() {
MENU=4
while [ $MENU -eq 4 ];do
if is_pi ; then if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "System Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \ FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "System Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Password" "Change password for the '$USER' user" \ "Password" "Change password for the '$USER' user" \
@@ -763,6 +883,7 @@ do_system_menu() {
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
return 0 return 0
MENU=0
elif [ $RET -eq 0 ]; then elif [ $RET -eq 0 ]; then
case "$FUN" in case "$FUN" in
Password*) do_change_pass ;; Password*) do_change_pass ;;
@@ -777,102 +898,13 @@ do_system_menu() {
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi fi
done
} }
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_urls;;
*) 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 \
"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_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
}
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 \
"'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_get_db_pwd;;
*root*) do_get_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_reconfig_birdnet_menu() { do_reconfig_birdnet_menu() {
MENU=3
while [ $MENU -eq 3 ];do
if is_pi ; then 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 \ 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" \ "Latitude " "Set the latitude your system should use" \
@@ -887,6 +919,7 @@ do_reconfig_birdnet_menu() {
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
return 0 return 0
MENU=0
elif [ $RET -eq 0 ]; then elif [ $RET -eq 0 ]; then
case "$FUN" in case "$FUN" in
Lat*) do_reget_lat;; Lat*) do_reget_lat;;
@@ -897,10 +930,12 @@ do_reconfig_birdnet_menu() {
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi fi
done
} }
do_config_birdnet_menu() { do_config_birdnet_menu() {
MENU=2
while [ $MENU -eq 2 ];do
if is_pi ; then 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 \ 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 \
"Latitude " "Set the latitude your system should use" \ "Latitude " "Set the latitude your system should use" \
@@ -916,6 +951,7 @@ do_config_birdnet_menu() {
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
return 0 return 0
MENU=0
elif [ $RET -eq 0 ]; then elif [ $RET -eq 0 ]; then
case "$FUN" in case "$FUN" in
Lat*) do_get_lat;; Lat*) do_get_lat;;
@@ -927,66 +963,51 @@ do_config_birdnet_menu() {
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi fi
} done
do_interface_menu() {
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Interfacing Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"SSH" "Enable/disable remote command line access using SSH" \
"VNC" "Enable/disable graphical remote access using RealVNC" \
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
SSH*) do_ssh ;;
VNC*) do_vnc ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
} }
do_internationalisation_menu() { do_internationalisation_menu() {
MENU=1
while [ $MENU -eq 1 ];do
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Localisation Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \ FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Localisation Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Locale" "Configure language and regional settings" \ "Locale" "Configure language and regional settings" \
"Time Zone" "Set the Time Zone" \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
return 0 return 0
MENU=0
elif [ $RET -eq 0 ]; then elif [ $RET -eq 0 ]; then
case "$FUN" in case "$FUN" in
Locale*) do_change_locale; insist_on_reboot;; Locale*) do_change_locale;;
Time*) do_change_timezone;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi fi
done
} }
# #
# Interactive use loop # Interactive use loop
# #
if [ "$INTERACTIVE" = True ]; then [ -e $CONFIG ] || touch $CONFIG
[ -e $CONFIG ] || touch $CONFIG calc_wt_size
calc_wt_size while [ "$USER" = "root" ] || [ -z "$USER" ]; do
while [ "$USER" = "root" ] || [ -z "$USER" ]; do
if ! USER=$(whiptail --inputbox "birdnet-pi-config could not determine the default user.\\n\\nWhat user should these settings apply to?" 20 60 pi 3>&1 1>&2 2>&3); then if ! USER=$(whiptail --inputbox "birdnet-pi-config could not determine the default user.\\n\\nWhat user should these settings apply to?" 20 60 pi 3>&1 1>&2 2>&3); then
return 0 return 0
fi fi
done done
while true; do while true; do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \ FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
"Step 1" "Configure language" \ "Step 1" "Configure language and timezone" \
"Step 2" "Configure BirdNET-Pi before installation" \ "Step 2" "Configure BirdNET-Pi before installation" \
"Step 3" "Install BirdNET-Pi" \ "Step 3" "Install BirdNET-Pi" \
"Reconfigure BirdNET-Pi" "Reconfigure BirdNET-Pi AFTER installation" \ "Step 4" "Reconfigure BirdNET-Pi AFTER installation" \
"Step 5" "Update BirdNET-Pi (run this if you changed anything in Step 4)" \
"System Options" "Configure system settings" \ "System Options" "Configure system settings" \
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
else
exit
fi
RET=$? RET=$?
if [ $RET -eq 1 ]; then if [ $RET -eq 1 ]; then
do_finish do_finish
@@ -995,12 +1016,10 @@ if [ "$INTERACTIVE" = True ]; then
*1) do_internationalisation_menu ;; *1) do_internationalisation_menu ;;
*2) do_config_birdnet_menu ;; *2) do_config_birdnet_menu ;;
*3) do_install_birdnet;; *3) do_install_birdnet;;
Reconf*) do_reconfig_birdnet_menu ;; *4) do_reconfig_birdnet_menu ;;
*5) do_update_birdnet;;
Sys*) do_system_menu ;; Sys*) do_system_menu ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
else
exit 1
fi fi
done done
fi
+1 -2
View File
@@ -21,7 +21,7 @@ fi
if ! [ -z ${db_pwd} ];then if ! [ -z ${db_pwd} ];then
sed -i s/'^DB_PWD=.*'/"DB_PWD=${db_pwd}"/g ${birdnet_conf} sed -i s/'^DB_PWD=.*'/"DB_PWD=${db_pwd}"/g ${birdnet_conf}
sudo -upi ${birdnetpi_dir}/scripts/update_db_pwd.sh ${birdnetpi_dir}/scripts/update_db_pwd.sh
fi fi
if ! [ -z ${db_root_pwd} ];then if ! [ -z ${db_root_pwd} ];then
@@ -33,7 +33,6 @@ if ! [ -z ${birdnetpi_url} ];then
sed -i s/'^BIRDNETPI_URL=.*'/"BIRDNETPI_URL=${birdnetpi_url/\/\//\\\/\\\/}"/g ${birdnet_conf} 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/'^EXTRACTIONLOG_URL=.*'/"EXTRACTIONLOG_URL=${extractionlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
sed -i s/'^BIRDNETLOG_URL=.*'/"BIRDNETLOG_URL=${birdnetlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf} sed -i s/'^BIRDNETLOG_URL=.*'/"BIRDNETLOG_URL=${birdnetlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
sudo -upi ${birdnetpi_dir}/scripts/update_birdnet.sh
fi fi
if ! [ -z ${new_sensitivity} ];then if ! [ -z ${new_sensitivity} ];then