adding maraidb support

This commit is contained in:
Patrick McGuire
2021-10-10 15:28:18 -04:00
parent 5873d8bb9b
commit 560cf34439
8 changed files with 130 additions and 30 deletions
+21 -7
View File
@@ -1,7 +1,24 @@
#!/usr/bin/env bash
# test to create a database from bash
mysql << 'EOF'
drop DATABASE birds;
# 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
mysql_secure_installation << EOF
y
${DB_ROOT_PWD}
${DB_ROOT_PWD}
y
y
y
EOF
mysql << EOF
drop database birds;
CREATE DATABASE IF NOT EXISTS birds;
USE birds;
@@ -18,11 +35,8 @@ CREATE TABLE IF NOT EXISTS detections (
Week INT,
Sens FLOAT,
Overlap FLOAT);
GRANT ALL ON birds.* TO 'birder'@'localhost' IDENTIFIED BY '${DB_PWD}' WITH GRANT OPTION;
LOAD DATA LOCAL INFILE '/home/pi/Birding-Pi/BirdDB.txt'
INTO TABLE detections
FIELDS TERMINATED BY ';';
SELECT * FROM detections;
exit
EOF
+1 -1
View File
@@ -9,7 +9,7 @@ set -e
# Remove temporary file
trap 'rm -f $TMPFILE' EXIT
source /etc/birdnet/birdnet.conf
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=12
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=15
# Set Variables
TMPFILE=$(mktemp)
+2
View File
@@ -61,6 +61,8 @@ install_birdnet() {
sudo pip3 install colorama==0.4.4
echo "Installing librosa"
sudo pip3 install librosa
echo "Installing mysql-connector-python"
sudo pip3 install mysql-connector-python
}
read -sp "\
+13
View File
@@ -126,6 +126,15 @@ get_ICE_PWD() {
fi
}
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
}
get_PUSHED() {
while true; do
read -n1 -p "Do you have a free App key to receive mobile notifications via Pushed.co?" YN
@@ -180,6 +189,7 @@ configure() {
get_RECS_DIR
get_LATITUDE
get_LONGITUDE
get_DB_PWDS
get_DO_EXTRACTIONS
get_DO_RECORDING
get_TIMESTAMP_FORMAT
@@ -437,6 +447,9 @@ 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
EOF
+16 -4
View File
@@ -15,6 +15,17 @@ install_scripts() {
rm /usr/local/bin/index.html
}
install_mariadb() {
if ! which mysql &> /dev/null;then
echo "Installing MariaDB Server"
apt -qqy update
apt -qqy install mariadb-server
echo "MariaDB Installed"
fi
echo "Initializing the database"
$(dirname ${my_dir})/createdb.sh
}
install_birdnet_analysis() {
if ! which mysql &> /dev/null;then
echo "Installing MariaDB Server"
@@ -305,7 +316,7 @@ RestartSec=3
Type=simple
User=${USER}
Environment=TERM=xterm-256color
ExecStart=/usr/local/bin/gotty -p 8080 --title-format "Birding-Pi Log" journalctl -fu birdnet_analysis.service
ExecStart=/usr/local/bin/gotty -p 8080 --title-format "Birding-Pi Log" journalctl -o cat -fu birdnet_analysis.service
[Install]
WantedBy=multi-user.target
@@ -322,7 +333,7 @@ RestartSec=3
Type=simple
User=${USER}
Environment=TERM=xterm-256color
ExecStart=/usr/local/bin/gotty -p 8888 --title-format "Extractions Log" journalctl -fu extraction.service
ExecStart=/usr/local/bin/gotty -p 8888 --title-format "Extractions Log" journalctl -o cat -fu extraction.service
[Install]
WantedBy=multi-user.target
@@ -372,9 +383,9 @@ install_sox() {
install_php() {
if ! which pip &> /dev/null || ! which php-fpm7.3;then
echo "Installing PHP and PHP-FPM"
echo "Installing PHP modules"
apt -qq update
apt install -qqy php php-fpm
apt install -qqy php php-fpm php7.3-mysql
else
echo "PHP and PHP-FPM installed"
fi
@@ -515,6 +526,7 @@ install_selected_services() {
install_gotty_logs
install_tmux
install_sox
install_mariadb
install_php
install_spectrogram_service
install_edit_birdnet_conf