new species notifier worth trying
This commit is contained in:
@@ -194,7 +194,7 @@ BIRDNET_USER=pi
|
|||||||
## it needs to analyze. Be sure this directory is readable and writable for
|
## it needs to analyze. Be sure this directory is readable and writable for
|
||||||
## the BIRDNET_USER. If you are going to be accessing a remote data-set, you
|
## the BIRDNET_USER. If you are going to be accessing a remote data-set, you
|
||||||
## still need to set this, as this will be where the remote directory gets
|
## still need to set this, as this will be where the remote directory gets
|
||||||
## mounted locally. See REMOTE_RECS_DIR below for mounting remote data-sets.
|
## mounted locally.
|
||||||
|
|
||||||
RECS_DIR=${HOME}/BirdSongs
|
RECS_DIR=${HOME}/BirdSongs
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ DO_EXTRACTIONS=y
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------------- Recording Service ----------------------------#
|
#----------------------------- Recording Service ----------------------------#
|
||||||
#_______________The two variables below can be set to enable __________________#
|
#____________________The variable below can be set to enable __________________#
|
||||||
#________________________the birdnet_recording.service ________________________#
|
#________________________the birdnet_recording.service ________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the recording. #
|
# Keep this EMPTY if you do not want this device to perform the recording. #
|
||||||
@@ -230,51 +230,6 @@ DO_EXTRACTIONS=y
|
|||||||
|
|
||||||
DO_RECORDING=y
|
DO_RECORDING=y
|
||||||
|
|
||||||
## TIMESTAMP_FORMAT is the format the recording service will use to name its
|
|
||||||
## files. Setting this variable to "12" will name the recorded (and extracted)
|
|
||||||
## files using the 12-hour AM/PM time format. Setting this variable to "24"
|
|
||||||
## will name the files using the 24-hour time format. See examples below:
|
|
||||||
#
|
|
||||||
## TIMESTAMP_FORMAT=12
|
|
||||||
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav
|
|
||||||
#
|
|
||||||
## TIMESTAMP_FORMAT=24
|
|
||||||
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav
|
|
||||||
|
|
||||||
|
|
||||||
TIMESTAMP_FORMAT=24
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#----------------- Mounting a remote directory with systemd -----------------#
|
|
||||||
#_______________The four variables below can be set to enable a_______________#
|
|
||||||
#___________________systemd.mount for analysis, extraction,____________________#
|
|
||||||
#______________________________or file-serving_________________________________#
|
|
||||||
|
|
||||||
# Leave these settings EMPTY if your data-set is local. #
|
|
||||||
|
|
||||||
## REMOTE is simply a setting for enabling the systemd.mount to use a remote
|
|
||||||
## filesystem for the data storage and service.
|
|
||||||
## Set this to Y or y to enable the systemd.mount.
|
|
||||||
|
|
||||||
REMOTE=
|
|
||||||
|
|
||||||
## REMOTE_HOST is the IP address, hostname, or domain name SSH should use to
|
|
||||||
## connect for FUSE to mount its remote directories locally.
|
|
||||||
|
|
||||||
REMOTE_HOST=
|
|
||||||
|
|
||||||
## REMOTE_USER is the user SSH will use to connect to the REMOTE_HOST.
|
|
||||||
|
|
||||||
REMOTE_USER=
|
|
||||||
|
|
||||||
## REMOTE_RECS_DIR is the directory on the REMOTE_HOST which contains the
|
|
||||||
## data-set SSHFS should mount to this system for local access. This is NOT the
|
|
||||||
## directory where you will access the data on this machine. See RECS_DIR for
|
|
||||||
## that.
|
|
||||||
|
|
||||||
REMOTE_RECS_DIR=
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------- Web-hosting/Caddy File-server -----------------------#
|
#----------------------- Web-hosting/Caddy File-server -----------------------#
|
||||||
#__________The two variables below can be set to enable web access_____________#
|
#__________The two variables below can be set to enable web access_____________#
|
||||||
|
|||||||
+2
-46
@@ -13,7 +13,7 @@ BIRDNET_USER=
|
|||||||
## it needs to analyze. Be sure this directory is readable and writable for
|
## it needs to analyze. Be sure this directory is readable and writable for
|
||||||
## the BIRDNET_USER. If you are going to be accessing a remote data-set, you
|
## the BIRDNET_USER. If you are going to be accessing a remote data-set, you
|
||||||
## still need to set this, as this will be where the remote directory gets
|
## still need to set this, as this will be where the remote directory gets
|
||||||
## mounted locally. See REMOTE_RECS_DIR below for mounting remote data-sets.
|
## mounted locally.
|
||||||
|
|
||||||
RECS_DIR=
|
RECS_DIR=
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ DO_EXTRACTIONS=
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------------- Recording Service ----------------------------#
|
#----------------------------- Recording Service ----------------------------#
|
||||||
#_______________The two variables below can be set to enable __________________#
|
#____________________The variable below can be set to enable __________________#
|
||||||
#________________________the birdnet_recording.service ________________________#
|
#________________________the birdnet_recording.service ________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the recording. #
|
# Keep this EMPTY if you do not want this device to perform the recording. #
|
||||||
@@ -51,50 +51,6 @@ DO_EXTRACTIONS=
|
|||||||
|
|
||||||
DO_RECORDING=
|
DO_RECORDING=
|
||||||
|
|
||||||
## TIMESTAMP_FORMAT is the format the recording service will use to name its
|
|
||||||
## files. Setting this variable to "12" will name the recorded (and extracted)
|
|
||||||
## files using the 12-hour AM/PM time format. Setting this variable to "24"
|
|
||||||
## will name the files using the 24-hour time format. See examples below:
|
|
||||||
#
|
|
||||||
## TIMESTAMP_FORMAT=12
|
|
||||||
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav
|
|
||||||
#
|
|
||||||
## TIMESTAMP_FORMAT=24
|
|
||||||
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav
|
|
||||||
|
|
||||||
|
|
||||||
TIMESTAMP_FORMAT=
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#----------------- Mounting a remote directory with systemd -----------------#
|
|
||||||
#_______________The four variables below can be set to enable a________________#
|
|
||||||
#___________________systemd.mount for analysis, extraction,____________________#
|
|
||||||
#______________________________or file-serving_________________________________#
|
|
||||||
|
|
||||||
# Leave these settings EMPTY if your data-set is local. #
|
|
||||||
|
|
||||||
## REMOTE is simply a setting for enabling the systemd.mount to use a remote
|
|
||||||
## filesystem for the data storage and service.
|
|
||||||
## Set this to Y or y to enable the systemd.mount.
|
|
||||||
|
|
||||||
REMOTE=
|
|
||||||
|
|
||||||
## REMOTE_HOST is the IP address, hostname, or domain name SSH should use to
|
|
||||||
## connect for FUSE to mount its remote directories locally.
|
|
||||||
|
|
||||||
REMOTE_HOST=
|
|
||||||
|
|
||||||
## REMOTE_USER is the user SSH will use to connect to the REMOTE_HOST.
|
|
||||||
|
|
||||||
REMOTE_USER=
|
|
||||||
|
|
||||||
## REMOTE_RECS_DIR is the directory on the REMOTE_HOST which contains the
|
|
||||||
## data-set SSHFS should mount to this system for local access. This is NOT the
|
|
||||||
## directory where you will access the data on this machine. See RECS_DIR for
|
|
||||||
## that.
|
|
||||||
|
|
||||||
REMOTE_RECS_DIR=
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------- Web-hosting/Caddy File-server -----------------------#
|
#----------------------- Web-hosting/Caddy File-server -----------------------#
|
||||||
#__________The two variables below can be set to enable web access_____________#
|
#__________The two variables below can be set to enable web access_____________#
|
||||||
|
|||||||
@@ -31,17 +31,6 @@ get_DO_EXTRACTIONS() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_TIMESTAMP_FORMAT() {
|
|
||||||
read -n2 -p "Would you like recordings to be time stamped in 12-hour AM/PM
|
|
||||||
or 24-hour format? " TIMESTAMP_FORMAT
|
|
||||||
echo
|
|
||||||
case $TIMESTAMP_FORMAT in
|
|
||||||
12 ) ;;
|
|
||||||
24 ) ;;
|
|
||||||
* ) TIMESTAMP_FORMAT=24;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
get_DO_RECORDING() {
|
get_DO_RECORDING() {
|
||||||
while true; do
|
while true; do
|
||||||
read -n1 -p "Is this device also doing the recording? " DO_RECORDING
|
read -n1 -p "Is this device also doing the recording? " DO_RECORDING
|
||||||
@@ -54,22 +43,6 @@ get_DO_RECORDING() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_REMOTE() {
|
|
||||||
while true; do
|
|
||||||
read -n1 -p "Are the recordings mounted on a remote file system?" REMOTE
|
|
||||||
echo
|
|
||||||
case $REMOTE in
|
|
||||||
[Yy] )
|
|
||||||
read -p "What is the remote hostname or IP address for the recorder? " REMOTE_HOST
|
|
||||||
read -p "Who is the remote user? " REMOTE_USER
|
|
||||||
read -p "What is the absolute path of the recordings directory on the remote host? " REMOTE_RECS_DIR
|
|
||||||
break;;
|
|
||||||
[Nn] ) break;;
|
|
||||||
* ) echo "Please answer Yes or No (y or n)";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
get_EXTRACTIONS_URL() {
|
get_EXTRACTIONS_URL() {
|
||||||
while true;do
|
while true;do
|
||||||
read -n1 -p "Would you like to access the extractions via a web browser?
|
read -n1 -p "Would you like to access the extractions via a web browser?
|
||||||
@@ -192,8 +165,6 @@ configure() {
|
|||||||
get_DB_PWDS
|
get_DB_PWDS
|
||||||
get_DO_EXTRACTIONS
|
get_DO_EXTRACTIONS
|
||||||
get_DO_RECORDING
|
get_DO_RECORDING
|
||||||
get_TIMESTAMP_FORMAT
|
|
||||||
get_REMOTE
|
|
||||||
get_EXTRACTIONS_URL
|
get_EXTRACTIONS_URL
|
||||||
get_PUSHED
|
get_PUSHED
|
||||||
get_INSTALL_NOMACHINE
|
get_INSTALL_NOMACHINE
|
||||||
@@ -242,7 +213,7 @@ DO_EXTRACTIONS=${DO_EXTRACTIONS}
|
|||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------------- Recording Service ----------------------------#
|
#----------------------------- Recording Service ----------------------------#
|
||||||
#_______________The two variables below can be set to enable __________________#
|
#____________________The variable below can be set to enable __________________#
|
||||||
#________________________the birdnet_recording.service ________________________#
|
#________________________the birdnet_recording.service ________________________#
|
||||||
|
|
||||||
# Keep this EMPTY if you do not want this device to perform the recording. #
|
# Keep this EMPTY if you do not want this device to perform the recording. #
|
||||||
@@ -253,51 +224,6 @@ DO_EXTRACTIONS=${DO_EXTRACTIONS}
|
|||||||
|
|
||||||
DO_RECORDING=${DO_RECORDING}
|
DO_RECORDING=${DO_RECORDING}
|
||||||
|
|
||||||
## TIMESTAMP_FORMAT is the format the recording service will use to name its
|
|
||||||
## files. Setting this variable to "12" will name the recorded (and extracted)
|
|
||||||
## files using the 12-hour AM/PM time format. Setting this variable to "24"
|
|
||||||
## will name the files using the 24-hour time format. See examples below:
|
|
||||||
#
|
|
||||||
## TIMESTAMP_FORMAT=12
|
|
||||||
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-01:00:19pm.wav
|
|
||||||
#
|
|
||||||
## TIMESTAMP_FORMAT=24
|
|
||||||
## example filename: 236-Northern_Cardinal-86%2021-09-30-birdnet-13:00:19.wav
|
|
||||||
|
|
||||||
|
|
||||||
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT}
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#----------------- Mounting a remote directory with systemd -----------------#
|
|
||||||
#_______________The four variables below can be set to enable a_______________#
|
|
||||||
#___________________systemd.mount for analysis, extraction,____________________#
|
|
||||||
#______________________________or file-serving_________________________________#
|
|
||||||
|
|
||||||
# Leave these settings EMPTY if your data-set is local. #
|
|
||||||
|
|
||||||
## REMOTE is simply a setting for enabling the systemd.mount to use a remote
|
|
||||||
## filesystem for the data storage and service.
|
|
||||||
## Set this to Y or y to enable the systemd.mount.
|
|
||||||
|
|
||||||
REMOTE=${REMOTE}
|
|
||||||
|
|
||||||
## REMOTE_HOST is the IP address, hostname, or domain name SSH should use to
|
|
||||||
## connect for FUSE to mount its remote directories locally.
|
|
||||||
|
|
||||||
REMOTE_HOST=${REMOTE_HOST}
|
|
||||||
|
|
||||||
## REMOTE_USER is the user SSH will use to connect to the REMOTE_HOST.
|
|
||||||
|
|
||||||
REMOTE_USER=${REMOTE_USER}
|
|
||||||
|
|
||||||
## REMOTE_RECS_DIR is the directory on the REMOTE_HOST which contains the
|
|
||||||
## data-set SSHFS should mount to this system for local access. This is NOT the
|
|
||||||
## directory where you will access the data on this machine. See RECS_DIR for
|
|
||||||
## that.
|
|
||||||
|
|
||||||
REMOTE_RECS_DIR=${REMOTE_RECS_DIR}
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#----------------------- Web-hosting/Caddy File-server -----------------------#
|
#----------------------- Web-hosting/Caddy File-server -----------------------#
|
||||||
#__________The two variables below can be set to enable web access_____________#
|
#__________The two variables below can be set to enable web access_____________#
|
||||||
|
|||||||
+31
-89
@@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# This installs the services that have been selected
|
# This installs the services that have been selected
|
||||||
#set -x # Uncomment to enable debugging
|
#set -x # Uncomment to enable debugging
|
||||||
trap 'rm -f ${TMPFILE}' EXIT
|
trap 'rm -f ${tmpfile}' EXIT
|
||||||
trap 'exit 1' SIGINT SIGHUP
|
trap 'exit 1' SIGINT SIGHUP
|
||||||
my_dir=$(realpath $(dirname $0))
|
USER=pi
|
||||||
TMPFILE=$(mktemp)
|
HOME=/home/pi
|
||||||
|
my_dir=${HOME}/BirdNET-Pi/scripts
|
||||||
|
tmpfile=$(mktemp)
|
||||||
nomachine_url="https://download.nomachine.com/download/7.6/Arm/nomachine_7.6.2_3_arm64.deb"
|
nomachine_url="https://download.nomachine.com/download/7.6/Arm/nomachine_7.6.2_3_arm64.deb"
|
||||||
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"
|
||||||
|
|
||||||
install_scripts() {
|
install_scripts() {
|
||||||
echo "Installing BirdNET-Pi scripts to /usr/local/bin"
|
echo "Installing BirdNET-Pi scripts to /usr/local/bin"
|
||||||
@@ -72,14 +74,23 @@ WantedBy=multi-user.target
|
|||||||
EOF
|
EOF
|
||||||
systemctl enable extraction.timer
|
systemctl enable extraction.timer
|
||||||
systemctl enable extraction.service
|
systemctl enable extraction.service
|
||||||
echo "Adding the species_updater.cron"
|
}
|
||||||
if ! crontab -u ${USER} -l &> /dev/null;then
|
|
||||||
crontab -u ${USER} $(dirname ${my_dir})/templates/species_updater.cron &> /dev/null
|
install_pushed_notifications() {
|
||||||
else
|
echo "Installing Pushed.co mobile notifications"
|
||||||
crontab -u ${USER} -l > ${TMPFILE}
|
cat << EOF > /etc/systemd/system/pushed_notifications.service
|
||||||
cat $(dirname ${my_dir})/templates/species_updater.cron >> ${TMPFILE}
|
[Unit]
|
||||||
crontab -u ${USER} "${TMPFILE}" &> /dev/null
|
Description=BirdNET-Pi Pushed.co Notifications
|
||||||
fi
|
[Service]
|
||||||
|
Restart=on-success
|
||||||
|
RestartSec=3
|
||||||
|
Type=simple
|
||||||
|
User=pi
|
||||||
|
ExecStart=/usr/local/bin/species_notifier.sh
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable --now pushed_notifications
|
||||||
}
|
}
|
||||||
|
|
||||||
create_necessary_dirs() {
|
create_necessary_dirs() {
|
||||||
@@ -138,51 +149,6 @@ EOF
|
|||||||
systemctl enable birdnet_recording.service
|
systemctl enable birdnet_recording.service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
install_sshfs() {
|
|
||||||
echo "Checking for SSHFS to mount remote filesystem"
|
|
||||||
if ! which sshfs &> /dev/null ;then
|
|
||||||
echo "Installing SSHFS"
|
|
||||||
apt -qqq update
|
|
||||||
apt install -qqqy sshfs
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_sshkeys() {
|
|
||||||
echo "Setting up SSH keys for SSHFS"
|
|
||||||
echo "Adding remote host key to ${HOME}/.ssh/known_hosts"
|
|
||||||
ssh-keyscan -H ${REMOTE_HOST} >> ${HOME}/.ssh/known_hosts
|
|
||||||
chown ${USER}:${USER} ${HOME}/.ssh/known_hosts &> /dev/null
|
|
||||||
if [ ! -f ${HOME}/.ssh/id_ed25519.pub ];then
|
|
||||||
echo "Creating a new key"
|
|
||||||
ssh-keygen -t ed25519 -f ${HOME}/.ssh/id_ed25519 -P ""
|
|
||||||
fi
|
|
||||||
chown -R ${USER}:${USER} ${HOME}/.ssh/ &> /dev/null
|
|
||||||
echo "Copying public key to ${REMOTE_HOST}"
|
|
||||||
ssh-copy-id ${REMOTE_USER}@${REMOTE_HOST}
|
|
||||||
}
|
|
||||||
|
|
||||||
install_systemd_mount() {
|
|
||||||
echo "Installing systemd.mount"
|
|
||||||
cat << EOF > /etc/systemd/system/${SYSTEMD_MOUNT}
|
|
||||||
[Unit]
|
|
||||||
Description=Mount remote fs with sshfs
|
|
||||||
DefaultDependencies=no
|
|
||||||
Conflicts=umount.target
|
|
||||||
After=network-online.target
|
|
||||||
Before=umount.target
|
|
||||||
Wants=network-online.target
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
[Mount]
|
|
||||||
What=${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_RECS_DIR}
|
|
||||||
Where=${RECS_DIR}
|
|
||||||
Type=fuse.sshfs
|
|
||||||
Options=delay_connect,_netdev,allow_other,IdentityFile=${HOME}/.ssh/id_ed25519,reconnect,ServerAliveInterval=30,ServerAliveCountMax=5,x-systemd.automount,uid=1000,gid=1000
|
|
||||||
TimeoutSec=60
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
install_caddy() {
|
install_caddy() {
|
||||||
if ! which caddy &> /dev/null ;then
|
if ! which caddy &> /dev/null ;then
|
||||||
echo "Installing Caddy"
|
echo "Installing Caddy"
|
||||||
@@ -433,25 +399,12 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_nomachine() {
|
install_nomachine() {
|
||||||
|
if [ ! -d /usr/share/NX ];then
|
||||||
echo "Installing NoMachine"
|
echo "Installing NoMachine"
|
||||||
cd ~
|
|
||||||
curl -s -O "${nomachine_url}"
|
curl -s -O "${nomachine_url}"
|
||||||
apt install -y ${HOME}/nomachine_7.6.2_3_arm64.deb
|
apt install -y ${HOME}/nomachine_7.6.2_3_arm64.deb
|
||||||
rm -f ${HOME}/nomachine_7.6.2_3_arm64.deb
|
rm -f ${HOME}/nomachine_7.6.2_3_arm64.deb
|
||||||
}
|
|
||||||
|
|
||||||
install_systemd_overrides() {
|
|
||||||
for i in caddy birdnet_analysis extraction birdnet_recording;do
|
|
||||||
if [ -f /etc/systemd/system/${i}.service ];then
|
|
||||||
[ -d /etc/systemd/system/${i}.d ] || mkdir /etc/systemd/system/${i}.d
|
|
||||||
echo "Installing the systemd overrides.conf for the ${i}.service"
|
|
||||||
cat << EOF > /etc/systemd/system/${i}.d/overrides.conf
|
|
||||||
[Unit]
|
|
||||||
After=network.target network-online.target ${SYSTEMD_MOUNT}
|
|
||||||
Requires=network-online.target ${SYSTEMD_MOUNT}
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_cleanup_cron() {
|
install_cleanup_cron() {
|
||||||
@@ -459,9 +412,9 @@ install_cleanup_cron() {
|
|||||||
if ! crontab -u ${USER} -l &> /dev/null;then
|
if ! crontab -u ${USER} -l &> /dev/null;then
|
||||||
crontab -u ${USER} $(dirname ${my_dir})/templates/cleanup.cron &> /dev/null
|
crontab -u ${USER} $(dirname ${my_dir})/templates/cleanup.cron &> /dev/null
|
||||||
else
|
else
|
||||||
crontab -u ${USER} -l > ${TMPFILE}
|
crontab -u ${USER} -l > ${tmpfile}
|
||||||
cat $(dirname ${my_dir})/templates/cleanup.cron >> ${TMPFILE}
|
cat $(dirname ${my_dir})/templates/cleanup.cron >> ${tmpfile}
|
||||||
crontab -u ${USER} "${TMPFILE}" &> /dev/null
|
crontab -u ${USER} "${tmpfile}" &> /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,12 +431,6 @@ install_selected_services() {
|
|||||||
install_recording_service
|
install_recording_service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${REMOTE}" =~ [Yy] ]];then
|
|
||||||
install_sshfs
|
|
||||||
setup_sshkeys
|
|
||||||
install_systemd_mount
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "${EXTRACTIONS_URL}" ];then
|
if [ ! -z "${EXTRACTIONS_URL}" ];then
|
||||||
install_caddy
|
install_caddy
|
||||||
install_Caddyfile
|
install_Caddyfile
|
||||||
@@ -494,6 +441,7 @@ install_selected_services() {
|
|||||||
install_php
|
install_php
|
||||||
install_spectrogram_service
|
install_spectrogram_service
|
||||||
install_edit_birdnet_conf
|
install_edit_birdnet_conf
|
||||||
|
install_pushed_notifications
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "${ICE_PWD}" ];then
|
if [ ! -z "${ICE_PWD}" ];then
|
||||||
@@ -505,19 +453,13 @@ install_selected_services() {
|
|||||||
install_nomachine
|
install_nomachine
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${REMOTE}" =~ [Yy] ]];then
|
|
||||||
install_systemd_overrides
|
|
||||||
fi
|
|
||||||
|
|
||||||
create_necessary_dirs
|
create_necessary_dirs
|
||||||
install_cleanup_cron
|
install_cleanup_cron
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f ${CONFIG_FILE} ];then
|
if [ -f ${config_file} ];then
|
||||||
source ${CONFIG_FILE}
|
source ${config_file}
|
||||||
USER=${BIRDNET_USER}
|
|
||||||
HOME="$(getent passwd ${BIRDNET_USER} | cut -d: -f6)"
|
|
||||||
install_selected_services
|
install_selected_services
|
||||||
else
|
else
|
||||||
echo "Unable to find a configuration file. Please make sure that $CONFIG_FILE exists."
|
echo "Unable to find a configuration file. Please make sure that $config_file exists."
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Sends a notification if a new species is detected
|
# Sends a notification if a new species is detected
|
||||||
#set -x
|
set -x
|
||||||
trap 'rm -f $tmpids' EXIT
|
trap 'rm -f $tmpids' EXIT
|
||||||
|
|
||||||
source /etc/birdnet/birdnet.conf
|
source /etc/birdnet/birdnet.conf
|
||||||
|
lastcheck="${IDFILE}.lastime"
|
||||||
tmpids=$(mktemp)
|
|
||||||
|
|
||||||
[ -f ${IDFILE} ] || touch ${IDFILE}
|
[ -f ${IDFILE} ] || touch ${IDFILE}
|
||||||
cat "${IDFILE}" > "${tmpids}"
|
cat "${IDFILE}" > "${lastcheck}"
|
||||||
|
|
||||||
/usr/local/bin/update_species.sh > /dev/null
|
/usr/local/bin/update_species.sh > /dev/null
|
||||||
|
|
||||||
if ! diff "${IDFILE}" "${tmpids}" &> /dev/null; then
|
if ! diff "${IDFILE}" "${lastcheck}" &> /dev/null; then
|
||||||
SPECIES=("$(diff "${IDFILE}" "${tmpids}" \
|
SPECIES=("$(diff "${IDFILE}" "${lastcheck}" \
|
||||||
| grep "Common Name" \
|
| grep "Common Name" \
|
||||||
| sort \
|
| sort \
|
||||||
| awk '{for(i=4;i<=NF;++i)printf $i""FS ; print ""}')")
|
| awk '{for(i=4;i<=NF;++i)printf $i""FS ; print ""}')")
|
||||||
|
|||||||
@@ -51,21 +51,19 @@ avahi-alias@birdnetpi.local.service
|
|||||||
avahi-alias@birdstats.local.service
|
avahi-alias@birdstats.local.service
|
||||||
avahi-alias@extractionlog.local.service
|
avahi-alias@extractionlog.local.service
|
||||||
avahi-alias@birdterminal.local.service
|
avahi-alias@birdterminal.local.service
|
||||||
birdnet_analysis.d
|
|
||||||
birdnet_analysis.service
|
birdnet_analysis.service
|
||||||
birdnet_log.service
|
birdnet_log.service
|
||||||
birdnet_recording.d
|
birdnet_recording.d
|
||||||
birdnet_recording.service
|
birdnet_recording.service
|
||||||
birdstats.service
|
birdstats.service
|
||||||
birdterminal.service
|
birdterminal.service
|
||||||
caddy.d
|
|
||||||
caddy.service
|
caddy.service
|
||||||
edit_birdnet_conf.service
|
edit_birdnet_conf.service
|
||||||
extraction_log.service
|
extraction_log.service
|
||||||
extraction.d
|
|
||||||
extraction.service
|
extraction.service
|
||||||
extraction.timer
|
extraction.timer
|
||||||
livestream.service
|
livestream.service
|
||||||
|
pushed_notifications.service
|
||||||
spectrogram_viewer.service
|
spectrogram_viewer.service
|
||||||
${SYSTEMD_MOUNT})
|
${SYSTEMD_MOUNT})
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ extraction_log.service
|
|||||||
extraction.service
|
extraction.service
|
||||||
extraction.timer
|
extraction.timer
|
||||||
livestream.service
|
livestream.service
|
||||||
|
pushed_notifications.service
|
||||||
spectrogram_viewer.service)
|
spectrogram_viewer.service)
|
||||||
|
|
||||||
remove_services() {
|
remove_services() {
|
||||||
@@ -134,6 +135,7 @@ extraction_log.service
|
|||||||
extraction.service
|
extraction.service
|
||||||
extraction.timer
|
extraction.timer
|
||||||
livestream.service
|
livestream.service
|
||||||
|
pushed_notifications.service
|
||||||
spectrogram_viewer.service)
|
spectrogram_viewer.service)
|
||||||
|
|
||||||
restart_services
|
restart_services
|
||||||
|
|||||||
+20
-38
@@ -72,14 +72,23 @@ WantedBy=multi-user.target
|
|||||||
EOF
|
EOF
|
||||||
systemctl enable extraction.timer
|
systemctl enable extraction.timer
|
||||||
systemctl enable extraction.service
|
systemctl enable extraction.service
|
||||||
echo "Adding the species_updater.cron"
|
}
|
||||||
if ! crontab -u ${USER} -l &> /dev/null;then
|
|
||||||
crontab -u ${USER} $(dirname ${my_dir})/templates/species_updater.cron &> /dev/null
|
install_pushed_notifications() {
|
||||||
else
|
echo "Installing Pushed.co mobile notifications"
|
||||||
crontab -u ${USER} -l > ${tmpfile}
|
cat << EOF > /etc/systemd/system/pushed_notifications.service
|
||||||
cat $(dirname ${my_dir})/templates/species_updater.cron >> ${tmpfile}
|
[Unit]
|
||||||
crontab -u ${USER} "${tmpfile}" &> /dev/null
|
Description=BirdNET-Pi Pushed.co Notifications
|
||||||
fi
|
[Service]
|
||||||
|
Restart=on-success
|
||||||
|
RestartSec=3
|
||||||
|
Type=simple
|
||||||
|
User=pi
|
||||||
|
ExecStart=/usr/local/bin/species_notifier.sh
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
systemctl enable --now pushed_notifications
|
||||||
}
|
}
|
||||||
|
|
||||||
create_necessary_dirs() {
|
create_necessary_dirs() {
|
||||||
@@ -138,16 +147,6 @@ EOF
|
|||||||
systemctl enable birdnet_recording.service
|
systemctl enable birdnet_recording.service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
install_sshfs() {
|
|
||||||
echo "Checking for SSHFS to mount remote filesystem"
|
|
||||||
if ! which sshfs &> /dev/null ;then
|
|
||||||
echo "Installing SSHFS"
|
|
||||||
apt -qqq update
|
|
||||||
apt install -qqqy sshfs
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
install_caddy() {
|
install_caddy() {
|
||||||
if ! which caddy &> /dev/null ;then
|
if ! which caddy &> /dev/null ;then
|
||||||
echo "Installing Caddy"
|
echo "Installing Caddy"
|
||||||
@@ -183,7 +182,7 @@ ${EXTRACTIONS_URL} {
|
|||||||
basicauth /stream {
|
basicauth /stream {
|
||||||
birdnet ${HASHWORD}
|
birdnet ${HASHWORD}
|
||||||
}
|
}
|
||||||
basicauth /phpsysinfo {
|
basicauth /phpsysinfo* {
|
||||||
birdnet ${HASHWORD}
|
birdnet ${HASHWORD}
|
||||||
}
|
}
|
||||||
reverse_proxy /stream localhost:8000
|
reverse_proxy /stream localhost:8000
|
||||||
@@ -202,7 +201,7 @@ http://birdnetpi.local {
|
|||||||
basicauth /stream {
|
basicauth /stream {
|
||||||
birdnet ${HASHWORD}
|
birdnet ${HASHWORD}
|
||||||
}
|
}
|
||||||
basicauth /phpsysinfo {
|
basicauth /phpsysinfo* {
|
||||||
birdnet ${HASHWORD}
|
birdnet ${HASHWORD}
|
||||||
}
|
}
|
||||||
reverse_proxy /stream localhost:8000
|
reverse_proxy /stream localhost:8000
|
||||||
@@ -405,20 +404,6 @@ install_nomachine() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_systemd_overrides() {
|
|
||||||
for i in caddy birdnet_analysis extraction birdnet_recording;do
|
|
||||||
if [ -f /etc/systemd/system/${i}.service ];then
|
|
||||||
[ -d /etc/systemd/system/${i}.d ] || mkdir /etc/systemd/system/${i}.d
|
|
||||||
echo "Installing the systemd overrides.conf for the ${i}.service"
|
|
||||||
cat << EOF > /etc/systemd/system/${i}.d/overrides.conf
|
|
||||||
[Unit]
|
|
||||||
After=network.target network-online.target ${SYSTEMD_MOUNT}
|
|
||||||
Requires=network-online.target ${SYSTEMD_MOUNT}
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
install_cleanup_cron() {
|
install_cleanup_cron() {
|
||||||
echo "Installing the cleanup.cron"
|
echo "Installing the cleanup.cron"
|
||||||
if ! crontab -u ${USER} -l &> /dev/null;then
|
if ! crontab -u ${USER} -l &> /dev/null;then
|
||||||
@@ -453,6 +438,7 @@ install_selected_services() {
|
|||||||
install_php
|
install_php
|
||||||
install_spectrogram_service
|
install_spectrogram_service
|
||||||
install_edit_birdnet_conf
|
install_edit_birdnet_conf
|
||||||
|
install_pushed_notifications
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "${ICE_PWD}" ];then
|
if [ ! -z "${ICE_PWD}" ];then
|
||||||
@@ -464,10 +450,6 @@ install_selected_services() {
|
|||||||
install_nomachine
|
install_nomachine
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${REMOTE}" =~ [Yy] ]];then
|
|
||||||
install_systemd_overrides
|
|
||||||
fi
|
|
||||||
|
|
||||||
create_necessary_dirs
|
create_necessary_dirs
|
||||||
install_cleanup_cron
|
install_cleanup_cron
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
After=network.target network-online.target ${SYSTEMD_MOUNT}
|
|
||||||
Requires=network-online.target ${SYSTEMD_MOUNT}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Mount remote fs with sshfs
|
|
||||||
DefaultDependencies=no
|
|
||||||
Conflicts=umount.target
|
|
||||||
After=network-online.target
|
|
||||||
Before=umount.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
||||||
[Mount]
|
|
||||||
What="${REMOTE_USER}"@"${REMOTE_HOST}":"${REMOTE_RECS_DIR}"
|
|
||||||
Where="${RECS_DIR}"
|
|
||||||
Type=fuse.sshfs
|
|
||||||
Options=delay_connect,_netdev,allow_other,IdentityFile=${HOME}/.ssh/id_ed25519,reconnect,ServerAliveInterval=30,ServerAliveCountMax=5,x-systemd.automount,uid=1000,gid=1000
|
|
||||||
TimeoutSec=60
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=BirdNET-Pi Pushed.co Notifications
|
||||||
|
[Service]
|
||||||
|
Restart=on-success
|
||||||
|
RestartSec=3
|
||||||
|
Type=simple
|
||||||
|
User=pi
|
||||||
|
ExecStart=/usr/local/bin/species_notifier.sh
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#birdnet
|
|
||||||
*/2 * * * * /usr/local/bin/species_notifier.sh &> /dev/null
|
|
||||||
Reference in New Issue
Block a user