Skip to content

A live bird collage card for your Home Assistant dashboard.

adusting for bullseye mariadb versions

Patrick McGuiredede5e97af71
diff --git a/Birders_Guide_Installer.sh b/Birders_Guide_Installer.sh
index 2ef92b51..45362df8 100755
--- a/Birders_Guide_Installer.sh
+++ b/Birders_Guide_Installer.sh
@@ -51,7 +51,7 @@ stage_2() {
fi
source ${my_dir}/Birders_Guide_Installer_Configuration.txt
- if [ -z ${LATITUDE} ] || [ -z ${LONGITUDE} ] || [ -z ${CADDY_PWD} ] || [ -z ${ICE_PWD} ] || [ -z ${DB_PWD} ] || [ -z ${DB_ROOT_PWD} ];then
+ if [ -z ${LATITUDE} ] || [ -z ${LONGITUDE} ] || [ -z ${CADDY_PWD} ] || [ -z ${ICE_PWD} ] || [ -z ${DB_PWD} ];then
echo
echo "Follow the instructions to fill out the LATITUDE and LONGITUDE variables
and set the passwords for the live audio stream. Save the file after editing
diff --git a/scripts/createdb.sh b/scripts/createdb_bullseye.sh
similarity index 100%
rename from scripts/createdb.sh
rename to scripts/createdb_bullseye.sh
diff --git a/scripts/createdb_buster.sh b/scripts/createdb_buster.sh
new file mode 100755
index 00000000..8f189929
--- /dev/null
+++ b/scripts/createdb_buster.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+# This script performs the mysql_secure_installation
+# Creates the birds database
+# Creates the detections table
+# Creates the birder user and grants them appropriate
+# permissions
+# If using this script to re-initialize (DROP then CREATE)
+# the DB, be sure to run this as root or with sudo
+source /etc/birdnet/birdnet.conf
+DB_ROOT_PWD=staggerwontonpurporting
+mysql_secure_installation << EOF
+
+y
+${DB_ROOT_PWD}
+${DB_ROOT_PWD}
+y
+y
+y
+EOF
+
+mysql << EOF
+DROP DATABASE IF EXISTS birds;
+CREATE DATABASE IF NOT EXISTS birds;
+
+USE birds;
+
+CREATE TABLE IF NOT EXISTS detections (
+ Date DATE,
+ Time TIME,
+ Sci_Name VARCHAR(100) NOT NULL,
+ Com_Name VARCHAR(100) NOT NULL,
+ Confidence FLOAT,
+ Lat FLOAT,
+ Lon FLOAT,
+ Cutoff FLOAT,
+ Week INT,
+ Sens FLOAT,
+ Overlap FLOAT);
+GRANT ALL ON birds.* TO 'birder'@'localhost' IDENTIFIED BY '${DB_PWD}' WITH GRANT OPTION;
+FLUSH PRIVILEGES;
+exit
+EOF
+sed -i "s/databasepassword/${DB_PWD}/g" /home/pi/BirdNET-Pi/analyze.py
+sed -i "s/databasepassword/${DB_PWD}/g" /home/pi/BirdNET-Pi/scripts/viewdb.php
diff --git a/scripts/install_config.sh b/scripts/install_config.sh
index e435af74..6623923c 100755
--- a/scripts/install_config.sh
+++ b/scripts/install_config.sh
@@ -103,8 +103,6 @@ get_DB_PWDS() {
if [ ! -z ${DB_PWD} ];then
read -p "Please set a password for your database: " DB_PWD
echo
- read -p "Please set a root password for the database: " DB_ROOT_PWD
- echo
fi
}
@@ -376,7 +374,6 @@ RECORDING_LENGTH=
EXTRACTION_LENGTH=
DB_PWD=${DB_PWD}
-DB_ROOT_PWD=${DB_ROOT_PWD}
LAST_RUN=$(dirname ${my_dir})/lastrun.txt
THIS_RUN=$(dirname ${my_dir})/thisrun.txt
diff --git a/scripts/install_services.sh b/scripts/install_services.sh
index e3400287..c6a7b368 100755
--- a/scripts/install_services.sh
+++ b/scripts/install_services.sh
@@ -34,7 +34,12 @@ install_mariadb() {
echo "MariaDB Installed"
fi
echo "Initializing the database"
- ${my_dir}/createdb.sh
+ source /etc/os-release
+ if [[ "${VERSION_CODENAME}" == "buster" ]];then
+ ${my_dir}/createdb_buster.sh
+ elif [[ "${VERSION_CODENAME}" == "bullseye" ]];then
+ ${my_dir}/createdb_bullseye.sh
+ fi
}
install_birdnet_analysis() {
diff --git a/scripts/rewrite_config.sh b/scripts/rewrite_config.sh
index 93ed90de..38f59f9f 100755
--- a/scripts/rewrite_config.sh
+++ b/scripts/rewrite_config.sh
@@ -24,11 +24,6 @@ sed -i s/'^DB_PWD=.*'/"DB_PWD=${db_pwd}"/g ${birdnet_conf}
${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}
diff --git a/scripts/update_db_pwd_bullseye.sh b/scripts/update_db_pwd_bullseye.sh
new file mode 100755
index 00000000..dae2656b
--- /dev/null
+++ b/scripts/update_db_pwd_bullseye.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+# Update database password
+source /etc/birdnet/birdnet.conf
+
+sudo mysql -e "
+ SET PASSWORD FOR 'birder'@'localhost' = PASSWORD('${DB_PWD}');
+ FLUSH PRIVILEGES";
+git -C /home/pi/BirdNET-Pi checkout -f analyze.py
+git -C /home/pi/BirdNET-Pi checkout -f scripts/viewdb.php
+sed -i "s/databasepassword/${DB_PWD}/g" /home/pi/BirdNET-Pi/analyze.py
+sed -i "s/databasepassword/${DB_PWD}/g" /home/pi/BirdNET-Pi/scripts/viewdb.php
diff --git a/scripts/update_db_pwd_buster.sh b/scripts/update_db_pwd_buster.sh
new file mode 100755
index 00000000..eba6dd0a
--- /dev/null
+++ b/scripts/update_db_pwd_buster.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# Update database password
+source /etc/birdnet/birdnet.conf
+
+sudo mysql -e "
+ UPDATE mysql.user
+ SET Password=PASSWORD('${DB_PWD}')
+ WHERE USER='birder'
+ AND Host='localhost';
+ FLUSH PRIVILEGES";
+git -C /home/pi/BirdNET-Pi checkout -f analyze.py
+git -C /home/pi/BirdNET-Pi checkout -f scripts/viewdb.php
+sed -i "s/databasepassword/${DB_PWD}/g" /home/pi/BirdNET-Pi/analyze.py
+sed -i "s/databasepassword/${DB_PWD}/g" /home/pi/BirdNET-Pi/scripts/viewdb.php
diff --git a/scripts/update_services.sh b/scripts/update_services.sh
index b20b7fdb..5f0ecd1f 100755
--- a/scripts/update_services.sh
+++ b/scripts/update_services.sh
@@ -33,7 +33,12 @@ install_mariadb() {
apt -qqy install mariadb-server
echo "MariaDB Installed"
fi
- ${my_dir}/update_db_pwd.sh
+ source /etc/os-release
+ if [[ "${VERSION_CODENAME}" == "buster" ]];then
+ ${my_dir}/update_db_pwd_buster.sh
+ elif [[ "${VERSION_CODENAME}" == "bullseye" ]];then
+ ${my_dir}/update_db_pwd_bullseye.sh
+ fi
}
install_birdnet_analysis() {
diff --git a/scripts/write_config.sh b/scripts/write_config.sh
index 424a7537..45ba6f84 100755
--- a/scripts/write_config.sh
+++ b/scripts/write_config.sh
@@ -7,7 +7,6 @@ sed -i s/'^LONGITUDE=$'/"LONGITUDE=${new_lon}"/g ${birders_conf}
sed -i s/'^CADDY_PWD=$'/"CADDY_PWD=${caddy_pwd}"/g ${birders_conf}
sed -i s/'^ICE_PWD=$'/"ICE_PWD=${ice_pwd}"/g ${birders_conf}
sed -i s/'^DB_PWD=$'/"DB_PWD=${db_pwd}"/g ${birders_conf}
-sed -i s/'^DB_ROOT_PWD=$'/"DB_ROOT_PWD=${db_root_pwd}"/g ${birders_conf}
sed -i s/'^BIRDNETPI_URL=$'/"BIRDNETPI_URL=${birdnetpi_url/\/\//\\\/\\\/}"/g ${birders_conf}
sed -i s/'^EXTRACTIONLOG_URL=$'/"EXTRACTIONLOG_URL=${extractionlog_url/\/\//\\\/\\\/}"/g ${birders_conf}
sed -i s/'^BIRDNETLOG_URL=$'/"BIRDNETLOG_URL=${birdnetlog_url/\/\//\\\/\\\/}"/g ${birders_conf}