adusting for bullseye mariadb versions

This commit is contained in:
Patrick McGuire
2021-11-10 14:02:26 -05:00
parent a1d2a05e56
commit dede5e97af
10 changed files with 82 additions and 12 deletions
+1 -1
View File
@@ -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
+44
View File
@@ -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
-3
View File
@@ -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
+6 -1
View File
@@ -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() {
-5
View File
@@ -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}
+11
View File
@@ -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
+14
View File
@@ -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
+6 -1
View File
@@ -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() {
-1
View File
@@ -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}