test new install

This commit is contained in:
mcguirepr89
2022-02-17 17:28:32 -05:00
parent 5455a682cd
commit 3ec62479fb
4 changed files with 227 additions and 119 deletions
+10 -42
View File
@@ -20,27 +20,26 @@ fi
sudo ./install_services.sh || exit 1 sudo ./install_services.sh || exit 1
source /etc/birdnet/birdnet.conf source /etc/birdnet/birdnet.conf
APT_DEPS=(swig ffmpeg wget unzip curl cmake make bc) apt_deps=(swig ffmpeg wget unzip curl cmake make bc)
LIBS_MODULES=(libjpeg-dev zlib1g-dev python3-dev python3-pip python3-venv) libs_modules=(libjpeg-dev zlib1g-dev python3-dev python3-pip python3-venv)
install_deps() { install_deps() {
echo " Checking dependencies" echo "Checking dependencies"
sudo apt update &> /dev/null for i in "${libs_modules[@]}";do
for i in "${LIBS_MODULES[@]}";do
if [ $(apt list --installed 2>/dev/null | grep "$i" | wc -l) -le 0 ];then if [ $(apt list --installed 2>/dev/null | grep "$i" | wc -l) -le 0 ];then
echo " Installing $i" echo " Installing $i"
sudo apt -y install ${i} &> /dev/null sudo apt -y install ${i} &> /dev/null
else else
echo " $i is installed!" echo "$i is installed!"
fi fi
done done
for i in "${APT_DEPS[@]}";do for i in "${apt_deps[@]}";do
if ! which $i &>/dev/null ;then if ! which $i &>/dev/null ;then
echo " Installing $i" echo "Installing $i"
sudo apt -y install ${i} &> /dev/null sudo apt -y install ${i} &> /dev/null
else else
echo " $i is installed!" echo "$i is installed!"
fi fi
done done
} }
@@ -51,21 +50,10 @@ install_birdnet() {
python3 -m venv birdnet python3 -m venv birdnet
source ./birdnet/bin/activate source ./birdnet/bin/activate
echo "Upgrading pip, wheel, and setuptools" echo "Upgrading pip, wheel, and setuptools"
pip3 install --upgrade pip~=21.0.0 wheel setuptools pip3 install --upgrade pip wheel setuptools
python_version="$(awk -F. '{print $2}' <(ls -l $(which /usr/bin/python3)))"
echo "python_version=${python_version}"
# TFLite Pre-built binaires from https://github.com/PINTO0309/TensorflowLite-bin # TFLite Pre-built binaires from https://github.com/PINTO0309/TensorflowLite-bin
# Python 3.7
if [[ "$python_version" == 7 ]];then
echo "Installing the TFLite bin wheel"
pip3 install --upgrade tflite_runtime-2.6.0-cp37-none-linux_aarch64.whl
fi
# Python 3.9
if [[ "$python_version" == 9 ]];then
echo "Installing the TFLite bin wheel" echo "Installing the TFLite bin wheel"
pip3 install --upgrade tflite_runtime-2.6.0-cp39-none-linux_aarch64.whl pip3 install --upgrade tflite_runtime-2.6.0-cp39-none-linux_aarch64.whl
fi
echo "Making sure everything else is installed" echo "Making sure everything else is installed"
pip3 install -U -r /home/pi/BirdNET-Pi/requirements.txt pip3 install -U -r /home/pi/BirdNET-Pi/requirements.txt
} }
@@ -76,24 +64,4 @@ install_deps
if [ ! -d ${VENV} ];then if [ ! -d ${VENV} ];then
install_birdnet install_birdnet
fi fi
exit 0
echo " BirdNet is installed!!
To start the service manually, issue:
'sudo systemctl start birdnet_analysis'
To monitor the service logs, issue:
'journalctl -fu birdnet_analysis'
To stop the service manually, issue:
'sudo systemctl stop birdnet_analysis'
To stop and disable the service, issue:
'sudo systemctl disable --now birdnet_analysis.service'
Visit
the BirdNET-Pi homepage at http://birdnetpi.local"
echo
case $YN in
[Yy] ) sudo systemctl start birdnet_analysis.service \
&& journalctl -fu birdnet_analysis;;
* ) echo " Thanks for installing BirdNET-Pi!!
I hope it was helpful!";;
esac
+188 -10
View File
@@ -6,20 +6,198 @@ trap 'exit 1' SIGINT SIGHUP
my_dir=$(realpath $(dirname $0)) my_dir=$(realpath $(dirname $0))
birdnetpi_dir=$(realpath $(dirname $my_dir)) birdnetpi_dir=$(realpath $(dirname $my_dir))
BIRDNET_CONF="$(dirname ${my_dir})/birdnet.conf" birdnet_conf="$(dirname ${my_dir})/birdnet.conf"
install_birdnet_conf() { install_config() {
cat << EOF > $(dirname ${my_dir})/birdnet.conf cat << EOF > $(dirname ${my_dir})/birdnet.conf
################################################################################
# Configuration settings for BirdNET-Pi #
################################################################################
#--------------------- Required: Latitude, and Longitude ----------------------#
## The shell substitution below guesses these based on your network. THESE NEED
## TO BE CHANGED TO STATIC VALUES
## Please only go to 4 decimal places. Example:43.3984
LATITUDE="$(curl -s4 ifconfig.co/json | awk '/lat/ {print $2}' | tr -d ',')"
LONGITUDE="$(curl -s4 ifconfig.co/json | awk '/lon/ {print $2}' | tr -d ',')"
#--------------------- BirdWeather Station Information -----------------------#
#_____________The variable below can be set to have your BirdNET-Pi____________#
#__________________also act as a BirdWeather listening station_________________#
BIRDWEATHER_ID=
#----------------------- Web Interface User Password ------------------------#
#____________________The variable below sets the 'birdnet'_____________________#
#___________________user password for the Live Audio Stream,___________________#
#_________________Tools, System Links, and the Processed files ________________#
## CADDY_PWD is the plaintext password (that will be hashed) and used to access
## certain parts of the web interface
CADDY_PWD=
#------------------------- Live Audio Stream --------------------------------#
#_____________The variable below configures/enables the live___________________#
#_____________________________audio stream.____________________________________#
## ICE_PWD is the password that icecast2 will use to authenticate ffmpeg as a
## trusted source for the stream. You will never need to enter this manually
## anywhere other than here and it stays on 'localhost.'
ICE_PWD=birdnetpi
#----------------------- Web-hosting/Caddy File-server -----------------------#
#_______The three variables below can be set to enable internet access_________#
#____________to your data,(e.g., extractions, raw data, live___________________#
#______________audio stream, BirdNET.selection.txt files)______________________#
## BIRDNETPI_URL is the URL where the extractions, data-set, and live-stream
## will be web-hosted. If you do not own a domain, or would just prefer to keep
## the BirdNET-Pi on your local network, keep this EMPTY.
BIRDNETPI_URL=
BIRDNETLOG_URL=
WEBTERMINAL_URL=
#------------------- Mobile Notifications via Pushed.co ---------------------#
#____________The two variables below enable mobile notifications_______________#
#_____________See https://pushed.co/quick-start-guide to get___________________#
#_________________________these values for your app.___________________________#
# Keep these EMPTY if haven't setup a Pushed.co App yet. #
## Pushed.co App Key and App Secret
PUSHED_APP_KEY=
PUSHED_APP_SECRET=
################################################################################
#-------------------------------- Defaults ----------------------------------#
################################################################################
## RECS_DIR is the location birdnet_analysis.service will look for the data-set
## it needs to analyze. Be sure this directory is readable and writable for
## the BIRDNET_USER.
RECS_DIR=/home/pi/BirdSongs
#------------------------------ Extraction Service ---------------------------#
## DO_EXTRACTIONS is simply a setting for enabling the extraction.service.
## Set this to Y or y to enable extractions.
DO_EXTRACTIONS=y
#----------------------------- Recording Service ----------------------------#
#____________________The variable below can be set to enable __________________#
#________________________the birdnet_recording.service ________________________#
## DO_RECORDING is simply a setting for enabling the 24/7
## birdnet_recording.service.
## Set this to Y or y to enable recording.
DO_RECORDING=y
## REC_CARD is the sound card you would want the birdnet_recording.service to
## use. Leave this as "default" to use PulseAudio (recommended), or use
## the output from "aplay -L" to specify an ALSA device.
REC_CARD=default
## PROCESSED is the directory where the formerly 'Analyzed' files are moved
## after extractions have been made from them. This includes both WAVE and
## BirdNET.selection.txt files.
PROCESSED=${RECS_DIR}/Processed
## EXTRACTED is the directory where the extracted audio selections are moved.
EXTRACTED=${RECS_DIR}/Extracted
## IDFILE is the file that keeps a complete list of every spececies that
## BirdNET has identified from your data-set. It is a relic and not really
## used anymore.
IDFILE=${HOME}/BirdNET-Pi/IdentifiedSoFar.txt
## OVERLAP is the value in seconds which BirdNET should use when analyzing
## the data. The values must be between 0.0-2.9.
OVERLAP=0.0
## CONFIDENCE is the minimum confidence level from 0.0-1.0 BirdNET's analysis
## should reach before creating an entry in the BirdNET.selection.txt file.
## Don't set this to 1.0 or you won't have any results.
CONFIDENCE=0.7
## SENSITIVITY is the detection sensitivity from 0.5-1.5.
SENSITIVITY=1.25
## CHANNELS holds the variable that corresponds to the number of channels the
## sound card supports.
CHANNELS=2
## FULL_DISK can be set to configure how the system reacts to a full disk
## purge = Remove the oldest day's worth of recordings
## keep = Keep all data and 'stop_core_services.sh'
FULL_DISK=purge
## VENV is the python virtual environment wherein all modules and site-packages
## have been installed.
VENV=/home/pi/BirdNET-Pi/birdnet
## RECORDING_LENGTH sets the length of the recording that BirdNET-Lite will
## analyze.
RECORDING_LENGTH=15
## EXTRACTION_LENGTH sets the length of the audio extractions that will be made
## from each BirdNET-Lite detection. An empty value will use the default of 6
## seconds.
EXTRACTION_LENGTH=
## AUDIOFMT set the audio format that sox should use for the extractions.
## The default is mp3. Available formats are: 8svx aif aifc aiff aiffc al amb
## amr-nb amr-wb anb au avr awb caf cdda cdr cvs cvsd cvu dat dvms f32 f4 f64 f8
## fap flac fssd gsm gsrt hcom htk ima ircam la lpc lpc10 lu mat mat4 mat5 maud
## mp2 mp3 nist ogg paf prc pvf raw s1 s16 s2 s24 s3 s32 s4 s8 sb sd2 sds sf sl
## sln smp snd sndfile sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 u32 u4 u8
## ub ul uw vms voc vorbis vox w64 wav wavpcm wv wve xa xi
## Note: Most have not been tested.
AUDIOFMT=mp3
## BIRDNET_USER should be the non-root user systemd should use to execute each
## service.
BIRDNET_USER=pi
## These are just for debugging
LAST_RUN=
THIS_RUN=
EOF EOF
} }
# Checks for a birdnet.conf file # Checks for a birdnet.conf file
if [ -f ${BIRDNET_CONF} ];then if ! [ -f ${birdnet_conf} ];then
source ${BIRDNET_CONF} install_config
chmod g+w ${BIRDNET_CONF}
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
sudo ln -sf $(dirname ${my_dir})/birdnet.conf /etc/birdnet/birdnet.conf
grep -ve '^#' -e '^$' /etc/birdnet/birdnet.conf > ${birdnetpi_dir}/firstrun.ini
else
echo "No birdnet.conf"; exit 1
fi fi
chmod g+w ${birdnet_conf}
[ -d /etc/birdnet ] || sudo mkdir /etc/birdnet
sudo ln -sf $(dirname ${my_dir})/birdnet.conf /etc/birdnet/birdnet.conf
grep -ve '^#' -e '^$' /etc/birdnet/birdnet.conf > ${birdnetpi_dir}/firstrun.ini
+29 -67
View File
@@ -11,6 +11,11 @@ nomachine_url="https://download.nomachine.com/download/7.7/Arm/nomachine_7.7.4_1
gotty_url="https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_arm.tar.gz" gotty_url="https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_arm.tar.gz"
config_file="$(dirname ${my_dir})/birdnet.conf" config_file="$(dirname ${my_dir})/birdnet.conf"
update_system() {
apt update && apt -y upgrade
}
set_hostname() { set_hostname() {
if [ "$(hostname)" == "raspberrypi" ];then if [ "$(hostname)" == "raspberrypi" ];then
echo "Setting hostname to 'birdnetpi'" echo "Setting hostname to 'birdnetpi'"
@@ -31,10 +36,6 @@ install_ftpd() {
fi fi
} }
update_system() {
apt update && apt -y upgrade
}
install_scripts() { install_scripts() {
echo "Installing BirdNET-Pi scripts to /usr/local/bin" echo "Installing BirdNET-Pi scripts to /usr/local/bin"
ln -sf ${my_dir}/* /usr/local/bin/ ln -sf ${my_dir}/* /usr/local/bin/
@@ -42,20 +43,13 @@ install_scripts() {
} }
install_mariadb() { install_mariadb() {
if ! which mysql &> /dev/null;then if ! which sqlite3 &> /dev/null;then
echo "Installing MariaDB Server" echo "Installing SQLite3"
apt -qqy update apt -qqy install sqlite3 php-sqlite3
apt -qqy install mariadb-server echo "SQLite Installed"
echo "MariaDB Installed"
fi fi
echo "Initializing the database" echo "Initializing the database"
source /etc/os-release ${my_dir}/createdb.sh
if [[ "${VERSION_CODENAME}" == "buster" ]];then
USER=${USER} ${my_dir}/createdb_buster.sh
elif [[ "${VERSION_CODENAME}" == "bullseye" ]];then
USER=${USER} ${my_dir}/createdb_bullseye.sh
fi
systemctl restart php${php_version}-fpm
} }
install_birdnet_analysis() { install_birdnet_analysis() {
@@ -186,7 +180,6 @@ create_necessary_dirs() {
fi fi
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewday.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/stats.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/stats.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED}
@@ -212,7 +205,7 @@ generate_BirdDB() {
sudo -u ${USER} sed -i '1 i\Date;Time;Sci_Name;Com_Name;Confidence;Lat;Lon;Cutoff;Week;Sens;Overlap' $(dirname ${my_dir})/BirdDB.txt sudo -u ${USER} sed -i '1 i\Date;Time;Sci_Name;Com_Name;Confidence;Lat;Lon;Cutoff;Week;Sens;Overlap' $(dirname ${my_dir})/BirdDB.txt
fi fi
ln -sf $(dirname ${my_dir})/BirdDB.txt ${my_dir}/BirdDB.txt && ln -sf $(dirname ${my_dir})/BirdDB.txt ${my_dir}/BirdDB.txt &&
chown pi:pi ${my_dir}/BirdDB.txt && chmod g+rw ${my_dir}/BirdDB.txt chown pi:pi ${my_dir}/BirdDB.txt && chmod g+rw ${my_dir}/BirdDB.txt
} }
install_alsa() { install_alsa() {
@@ -221,7 +214,6 @@ install_alsa() {
echo "alsa-utils installed" echo "alsa-utils installed"
else else
echo "Installing alsa-utils" echo "Installing alsa-utils"
apt -qqq update
apt install -qqy alsa-utils apt install -qqy alsa-utils
echo "alsa-utils installed" echo "alsa-utils installed"
fi fi
@@ -229,7 +221,6 @@ install_alsa() {
echo "PulseAudio installed" echo "PulseAudio installed"
else else
echo "Installing pulseaudio" echo "Installing pulseaudio"
apt -qqq update
apt install -qqy pulseaudio apt install -qqy pulseaudio
echo "PulseAudio installed" echo "PulseAudio installed"
fi fi
@@ -285,7 +276,6 @@ install_Caddyfile() {
if [ -f /etc/caddy/Caddyfile ];then if [ -f /etc/caddy/Caddyfile ];then
cp /etc/caddy/Caddyfile{,.original} cp /etc/caddy/Caddyfile{,.original}
fi fi
php_version="$(awk -F'php' '{print $3}' <(ls -l $(which /etc/alternatives/php)))"
if ! [ -z ${CADDY_PWD} ];then if ! [ -z ${CADDY_PWD} ];then
HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD}) HASHWORD=$(caddy hash-password -plaintext ${CADDY_PWD})
cat << EOF > /etc/caddy/Caddyfile cat << EOF > /etc/caddy/Caddyfile
@@ -305,7 +295,7 @@ http://localhost http://$(hostname).local ${BIRDNETPI_URL} {
birdnet ${HASHWORD} birdnet ${HASHWORD}
} }
reverse_proxy /stream localhost:8000 reverse_proxy /stream localhost:8000
php_fastcgi unix//run/php/php${php_version}-fpm.sock php_fastcgi unix//run/php/php7.4-fpm.sock
} }
EOF EOF
else else
@@ -314,7 +304,7 @@ http://localhost http://$(hostname).local ${BIRDNETPI_URL} {
root * ${EXTRACTED} root * ${EXTRACTED}
file_server browse file_server browse
reverse_proxy /stream localhost:8000 reverse_proxy /stream localhost:8000
php_fastcgi unix//run/php/php${php_version}-fpm.sock php_fastcgi unix//run/php/php7.4-fpm.sock
} }
EOF EOF
fi fi
@@ -453,7 +443,6 @@ install_sox() {
echo "Sox is installed" echo "Sox is installed"
else else
echo "Installing sox" echo "Installing sox"
apt -qq update
apt install -y sox libsox-fmt-mp3 apt install -y sox libsox-fmt-mp3
echo "Sox installed" echo "Sox installed"
fi fi
@@ -485,7 +474,6 @@ EOF
install_icecast() { install_icecast() {
if ! which icecast2;then if ! which icecast2;then
echo "Installing IceCast2" echo "Installing IceCast2"
apt -qq update
echo "icecast2 icecast2/icecast-setup boolean false" | debconf-set-selections echo "icecast2 icecast2/icecast-setup boolean false" | debconf-set-selections
apt install -qqy icecast2 apt install -qqy icecast2
config_icecast config_icecast
@@ -530,17 +518,6 @@ EOF
systemctl enable livestream.service systemctl enable livestream.service
} }
install_nomachine() {
if [ ! -d /usr/share/NX ] && [ -d /etc/lightdm ];then
echo "Installing NoMachine"
curl -s -o ${HOME}/nomachine.deb -O "${nomachine_url}"
apt install -y ${HOME}/nomachine.deb
rm -f ${HOME}/nomachine.deb
echo "Enabling VNC"
systemctl enable --now vncserver-x11-serviced.service
fi
}
install_cleanup_cron() { install_cleanup_cron() {
echo "Installing the cleanup.cron" echo "Installing the cleanup.cron"
cat $(dirname ${my_dir})/templates/cleanup.cron >> /etc/crontab cat $(dirname ${my_dir})/templates/cleanup.cron >> /etc/crontab
@@ -552,37 +529,22 @@ install_selected_services() {
install_scripts install_scripts
install_birdnet_analysis install_birdnet_analysis
install_birdnet_server install_birdnet_server
install_extraction_service
if [[ "${DO_EXTRACTIONS}" =~ [Yy] ]];then install_alsa
install_extraction_service install_recording_service
fi install_php
install_caddy
if [[ "${DO_RECORDING}" =~ [Yy] ]];then install_Caddyfile
install_alsa update_etc_hosts
install_recording_service install_avahi_aliases
fi install_gotty_logs
install_sox
install_php install_mariadb
install_caddy install_spectrogram_service
install_Caddyfile install_chart_viewer_service
update_etc_hosts install_pushed_notifications
install_avahi_aliases install_icecast
install_gotty_logs install_livestream_service
install_sox
install_mariadb
install_spectrogram_service
install_chart_viewer_service
install_pushed_notifications
if [ ! -z "${ICE_PWD}" ];then
install_icecast
install_livestream_service
fi
if [[ "${INSTALL_NOMACHINE}" =~ [Yy] ]];then
install_nomachine
fi
create_necessary_dirs create_necessary_dirs
generate_BirdDB generate_BirdDB
install_cleanup_cron install_cleanup_cron