working on update button
This commit is contained in:
+25
-70
@@ -1,13 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# This installs the services that have been selected
|
||||
#set -x # Uncomment to enable debugging
|
||||
trap 'rm -f ${TMPFILE}' EXIT
|
||||
trap 'rm -f ${tmpfile}' EXIT
|
||||
trap 'exit 1' SIGINT SIGHUP
|
||||
my_dir=$(realpath $(dirname $0))
|
||||
TMPFILE=$(mktemp)
|
||||
USER=pi
|
||||
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"
|
||||
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() {
|
||||
echo "Installing BirdNET-Pi scripts to /usr/local/bin"
|
||||
@@ -22,8 +24,6 @@ install_mariadb() {
|
||||
apt -qqy install mariadb-server
|
||||
echo "MariaDB Installed"
|
||||
fi
|
||||
echo "Initializing the database"
|
||||
# ${my_dir}/createdb.sh
|
||||
}
|
||||
|
||||
install_birdnet_analysis() {
|
||||
@@ -76,9 +76,9 @@ EOF
|
||||
if ! crontab -u ${USER} -l &> /dev/null;then
|
||||
crontab -u ${USER} $(dirname ${my_dir})/templates/species_updater.cron &> /dev/null
|
||||
else
|
||||
crontab -u ${USER} -l > ${TMPFILE}
|
||||
cat $(dirname ${my_dir})/templates/species_updater.cron >> ${TMPFILE}
|
||||
crontab -u ${USER} "${TMPFILE}" &> /dev/null
|
||||
crontab -u ${USER} -l > ${tmpfile}
|
||||
cat $(dirname ${my_dir})/templates/species_updater.cron >> ${tmpfile}
|
||||
crontab -u ${USER} "${tmpfile}" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ create_necessary_dirs() {
|
||||
[ -L ${EXTRACTED}/viewdb.php ] || sudo -u ${USER} ln -s $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED}
|
||||
sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED}
|
||||
[ -L ${EXTRACTED}/phpsysinfo.ini ] || sudo -u ${USER} cp ${HOME}/phpsysinfo/phpsysinfo.ini.new ${HOME}/phpsysinfo/phpsysinfo.ini
|
||||
|
||||
}
|
||||
|
||||
install_alsa() {
|
||||
@@ -146,41 +147,6 @@ install_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() {
|
||||
if ! which caddy &> /dev/null ;then
|
||||
echo "Installing Caddy"
|
||||
@@ -199,7 +165,6 @@ install_caddy() {
|
||||
install_Caddyfile() {
|
||||
echo "Installing the Caddyfile"
|
||||
[ -d /etc/caddy ] || mkdir /etc/caddy
|
||||
sudo -u ${USER} ln -sf $(dirname ${my_dir})/templates/index.html ${EXTRACTED}/
|
||||
if [ -f /etc/caddy/Caddyfile ];then
|
||||
cp /etc/caddy/Caddyfile{,.original}
|
||||
fi
|
||||
@@ -217,6 +182,9 @@ ${EXTRACTIONS_URL} {
|
||||
basicauth /stream {
|
||||
birdnet ${HASHWORD}
|
||||
}
|
||||
basicauth /phpsysinfo {
|
||||
birdnet ${HASHWORD}
|
||||
}
|
||||
reverse_proxy /stream localhost:8000
|
||||
php_fastcgi unix//run/php/php7.3-fpm.sock
|
||||
}
|
||||
@@ -233,17 +201,12 @@ http://birdnetpi.local {
|
||||
basicauth /stream {
|
||||
birdnet ${HASHWORD}
|
||||
}
|
||||
basicauth /phpsysinfo {
|
||||
birdnet ${HASHWORD}
|
||||
}
|
||||
reverse_proxy /stream localhost:8000
|
||||
php_fastcgi unix//run/php/php7.3-fpm.sock
|
||||
}
|
||||
|
||||
http://birdlog.local {
|
||||
reverse_proxy localhost:8080
|
||||
}
|
||||
|
||||
http://extractionlog.local {
|
||||
reverse_proxy localhost:8888
|
||||
}
|
||||
EOF
|
||||
systemctl reload caddy
|
||||
}
|
||||
@@ -344,7 +307,7 @@ install_sox() {
|
||||
}
|
||||
|
||||
install_php() {
|
||||
if ! which pip &> /dev/null || ! which php-fpm7.3;then
|
||||
if ! which php &> /dev/null || ! which php-fpm7.3 || ! apt list --installed | grep php-xml;then
|
||||
echo "Installing PHP modules"
|
||||
apt -qq update
|
||||
apt install -qqy php php-fpm php7.3-mysql php-xml
|
||||
@@ -353,7 +316,6 @@ install_php() {
|
||||
fi
|
||||
echo "Configuring PHP for Caddy"
|
||||
sed -i 's/www-data/caddy/g' /etc/php/7.3/fpm/pool.d/www.conf
|
||||
systemctl restart php7.3-fpm.service
|
||||
echo "Adding Caddy sudoers rule"
|
||||
cat << EOF > /etc/sudoers.d/010_caddy-nopasswd
|
||||
caddy ALL=(ALL) NOPASSWD: ALL
|
||||
@@ -434,11 +396,12 @@ EOF
|
||||
}
|
||||
|
||||
install_nomachine() {
|
||||
if [ ! -d /usr/share/NX ];then
|
||||
echo "Installing NoMachine"
|
||||
cd ~
|
||||
curl -s -O "${nomachine_url}"
|
||||
apt install -y ${HOME}/nomachine_7.6.2_3_arm64.deb
|
||||
rm -f ${HOME}/nomachine_7.6.2_3_arm64.deb
|
||||
fi
|
||||
}
|
||||
|
||||
install_systemd_overrides() {
|
||||
@@ -460,9 +423,9 @@ install_cleanup_cron() {
|
||||
if ! crontab -u ${USER} -l &> /dev/null;then
|
||||
crontab -u ${USER} $(dirname ${my_dir})/templates/cleanup.cron &> /dev/null
|
||||
else
|
||||
crontab -u ${USER} -l > ${TMPFILE}
|
||||
cat $(dirname ${my_dir})/templates/cleanup.cron >> ${TMPFILE}
|
||||
crontab -u ${USER} "${TMPFILE}" &> /dev/null
|
||||
crontab -u ${USER} -l > ${tmpfile}
|
||||
cat $(dirname ${my_dir})/templates/cleanup.cron >> ${tmpfile}
|
||||
crontab -u ${USER} "${tmpfile}" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -479,12 +442,6 @@ install_selected_services() {
|
||||
install_recording_service
|
||||
fi
|
||||
|
||||
if [[ "${REMOTE}" =~ [Yy] ]];then
|
||||
install_sshfs
|
||||
setup_sshkeys
|
||||
install_systemd_mount
|
||||
fi
|
||||
|
||||
if [ ! -z "${EXTRACTIONS_URL}" ];then
|
||||
install_caddy
|
||||
install_Caddyfile
|
||||
@@ -514,11 +471,9 @@ install_selected_services() {
|
||||
install_cleanup_cron
|
||||
}
|
||||
|
||||
if [ -f ${CONFIG_FILE} ];then
|
||||
source ${CONFIG_FILE}
|
||||
USER=${BIRDNET_USER}
|
||||
HOME="$(getent passwd ${BIRDNET_USER} | cut -d: -f6)"
|
||||
if [ -f ${config_file} ];then
|
||||
source ${config_file}
|
||||
install_selected_services
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user