From 1f51e96cb11f9df0a60a99f241502a6c46a8264b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:43:32 +0200 Subject: [PATCH] Refactor: Headscale (#6180) --- ct/headscale.sh | 13 ++++++------- install/headscale-install.sh | 11 ++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ct/headscale.sh b/ct/headscale.sh index 552a453fb..7ec236fa0 100644 --- a/ct/headscale.sh +++ b/ct/headscale.sh @@ -27,18 +27,17 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + if [[ -f /opt/${APP}_version.txt ]]; then + mv /opt/"${APP}_version.txt" ~/.headscale + fi + RELEASE=$(curl -fsSL https://api.github.com/repos/juanfont/headscale/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat ~/.headscale 2>/dev/null)" ]] || [[ ! -f ~/.headscale ]]; then msg_info "Stopping ${APP}" systemctl stop headscale msg_ok "Stopped ${APP}" - msg_info "Updating $APP to v${RELEASE}" - curl -fsSL "https://github.com/juanfont/headscale/releases/download/v${RELEASE}/headscale_${RELEASE}_linux_amd64.deb" -o $(basename "https://github.com/juanfont/headscale/releases/download/v${RELEASE}/headscale_${RELEASE}_linux_amd64.deb") - dpkg -i headscale_${RELEASE}_linux_amd64.deb - rm headscale_${RELEASE}_linux_amd64.deb - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to ${RELEASE}" + fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary" msg_info "Starting ${APP}" # Temporary fix until headscale project resolves service getting disabled on updates. diff --git a/install/headscale-install.sh b/install/headscale-install.sh index 4a3cd1f3a..cf28206ad 100644 --- a/install/headscale-install.sh +++ b/install/headscale-install.sh @@ -13,19 +13,16 @@ setting_up_container network_check update_os -RELEASE=$(curl -fsSL https://api.github.com/repos/juanfont/headscale/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -msg_info "Installing ${APPLICATION} v${RELEASE}" -curl -fsSL "https://github.com/juanfont/headscale/releases/download/v${RELEASE}/headscale_${RELEASE}_linux_amd64.deb" -o "headscale_${RELEASE}_linux_amd64.deb" -$STD dpkg -i headscale_${RELEASE}_linux_amd64.deb +fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary" + +msg_info "Starting service" systemctl enable -q --now headscale -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed ${APPLICATION} v${RELEASE}" +msg_ok "Service started" motd_ssh customize msg_info "Cleaning up" -rm headscale_${RELEASE}_linux_amd64.deb $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"