diff --git a/ct/watchyourlan.sh b/ct/watchyourlan.sh index 1921bdd89..5fb514ca9 100644 --- a/ct/watchyourlan.sh +++ b/ct/watchyourlan.sh @@ -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 } diff --git a/install/watchyourlan-install.sh b/install/watchyourlan-install.sh index efdf9e2b8..3f61d58e7 100644 --- a/install/watchyourlan-install.sh +++ b/install/watchyourlan-install.sh @@ -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 </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