Refactor: WatchYourLAN (#6871)

* Refactor

* Update
This commit is contained in:
Slaviša Arežina 2025-08-15 12:57:16 +02:00 committed by GitHub
parent 39b9cfcffc
commit 66687c0d21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 18 deletions

View File

@ -27,17 +27,25 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Updating $APP"
systemctl stop watchyourlan.service
cp -R /data/config.yaml config.yaml
RELEASE=$(curl -fsSL https://api.github.com/repos/aceberg/WatchYourLAN/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d '"' -f 4)
curl -fsSL "https://github.com/aceberg/WatchYourLAN/releases/download/$RELEASE/watchyourlan_${RELEASE}_linux_amd64.deb" -o $(basename "https://github.com/aceberg/WatchYourLAN/releases/download/$RELEASE/watchyourlan_${RELEASE}_linux_amd64.deb")
dpkg -i watchyourlan_${RELEASE}_linux_amd64.deb
cp -R config.yaml /data/config.yaml
sed -i 's|/etc/watchyourlan/config.yaml|/data/config.yaml|' /lib/systemd/system/watchyourlan.service
rm watchyourlan_${RELEASE}_linux_amd64.deb config.yaml
systemctl enable -q --now watchyourlan
msg_ok "Updated $APP"
RELEASE=$(curl -fsSL https://api.github.com/repos/aceberg/WatchYourLAN/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping service"
systemctl stop watchyourlan.service
msg_ok "Service stopped"
cp -R /data/config.yaml ~/config.yaml
fetch_and_deploy_gh_release "watchyourlan" "aceberg/WatchYourLAN" "binary"
cp -R config.yaml /data/config.yaml
sed -i 's|/etc/watchyourlan/config.yaml|/data/config.yaml|' /lib/systemd/system/watchyourlan.service
msg_info "Cleaning up"
rm ~/config.yaml
msg_ok "Cleaned up"
msg_info "Starting service"
systemctl enable -q --now watchyourlan
msg_ok "Service started"
exit
}

View File

@ -14,14 +14,15 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y {arp-scan,ieee-data,libwww-perl}
$STD apt-get install -y \
arp-scan \
ieee-data \
libwww-perl
msg_ok "Installed Dependencies"
msg_info "Installing WatchYourLAN"
RELEASE=$(curl -fsSL https://api.github.com/repos/aceberg/WatchYourLAN/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d '"' -f 4)
curl -fsSL "https://github.com/aceberg/WatchYourLAN/releases/download/$RELEASE/watchyourlan_${RELEASE}_linux_amd64.deb" -o "watchyourlan_${RELEASE}_linux_amd64.deb"
$STD dpkg -i watchyourlan_${RELEASE}_linux_amd64.deb
rm watchyourlan_${RELEASE}_linux_amd64.deb
fetch_and_deploy_gh_release "watchyourlan" "aceberg/WatchYourLAN" "binary"
msg_info "Configuring WatchYourLAN"
mkdir /data
cat <<EOF >/data/config.yaml
arp_timeout: "500"
@ -41,7 +42,7 @@ shoutrrr_url: ""
theme: solar
timeout: 60
EOF
msg_ok "Installed WatchYourLAN"
msg_ok "Configured WatchYourLAN"
msg_info "Creating Service"
sed -i 's|/etc/watchyourlan/config.yaml|/data/config.yaml|' /lib/systemd/system/watchyourlan.service