Skip to content

Commit

Permalink
Add past_birdweather_publication in install scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tvoirand committed Dec 7, 2024
1 parent 0374850 commit 0bdc488
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
30 changes: 30 additions & 0 deletions scripts/install_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,33 @@ install_tmp_mount() {
echo "tmp.mount is $STATE, skipping"
fi
}

install_birdweather_past_publication() {
cat << EOF > $HOME/BirdNET-Pi/templates/[email protected]
[Unit]
Description=BirdWeather Publication for %i interface
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
User=${USER}
ExecStartPre= /bin/sh -c 'n=0; until curl --silent --head --fail https://app.birdweather.com || [ \$n -ge 30 ]; do n=\$((n+1)); sleep 5; done;'
ExecStart=$PYTHON_VIRTUAL_ENV /usr/local/bin/birdweather_past_publication.py
EOF
cat << EOF > $HOME/BirdNET-Pi/templates/50-birdweather-past-publication
#!/bin/bash
UNIT_NAME="birdweather_past_publication@\$IFACE.service"
# Check if the service is active and then start it
if systemctl is-active --quiet "\$UNIT_NAME"; then
echo "\$UNIT_NAME is already running."
else
echo "Starting \$UNIT_NAME..."
systemctl start "\$UNIT_NAME"
fi
EOF
chmod +x $HOME/BirdNET-Pi/templates/50-birdweather-past-publication
chown root:root $HOME/BirdNET-Pi/templates/50-birdweather-past-publication
ln -sf $HOME/BirdNET-Pi/templates/50-birdweather-past-publication /etc/networkd-dispatcher/routable.d
ln -sf $HOME/BirdNET-Pi/templates/[email protected] /usr/lib/systemd/system
systemctl enable systemd-networkd
}
10 changes: 9 additions & 1 deletion scripts/install_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install_depends() {
apt install -qqy caddy sqlite3 php-sqlite3 php-fpm php-curl php-xml php-zip php icecast2 \
pulseaudio avahi-utils sox libsox-fmt-mp3 alsa-utils ffmpeg \
wget curl unzip bc \
python3-pip python3-venv lsof net-tools inotify-tools
python3-pip python3-venv lsof net-tools inotify-tools networkd-dispatcher
}

set_hostname() {
Expand Down Expand Up @@ -387,6 +387,13 @@ install_weekly_cron() {

chown_things() {
chown -R $USER:$USER $HOME/Bird*

# Set ownership to root for the birdweather publication networkd-dispatcher script
BIRDWEATHER_PAST_DISPATCHER_SCRIPT="$HOME/BirdNET-Pi/templates/50-birdweather-past-publication"
if [ -f "$BIRDWEATHER_PAST_DISPATCHER_SCRIPT" ]; then
sudo chown root:root "$BIRDWEATHER_PAST_DISPATCHER_SCRIPT"
sudo chmod 755 "$BIRDWEATHER_PAST_DISPATCHER_SCRIPT"
fi
}

increase_caddy_timeout() {
Expand All @@ -409,6 +416,7 @@ install_services() {
install_Caddyfile
install_avahi_aliases
install_birdnet_analysis
install_birdweather_past_publication
install_birdnet_stats_service
install_recording_service
install_custom_recording_service # But does not enable
Expand Down

0 comments on commit 0bdc488

Please sign in to comment.