From 9aafb65a982e9889e8603d3973bc43d1d705d7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Mon, 18 Aug 2025 22:12:22 +0200 Subject: [PATCH] Refactor: Traefik (#6940) * Refactor * typo --------- Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- ct/traefik.sh | 24 ++++++++++++++---------- frontend/public/json/traefik.json | 2 +- install/traefik-install.sh | 12 ++---------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/ct/traefik.sh b/ct/traefik.sh index 7c588df3d2..a7044a7fd1 100644 --- a/ct/traefik.sh +++ b/ct/traefik.sh @@ -27,16 +27,20 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - RELEASE=$(curl -fsSL https://api.github.com/repos/traefik/traefik/releases | grep -oP '"tag_name":\s*"v\K[\d.]+?(?=")' | sort -V | tail -n 1) - msg_info "Updating $APP LXC" - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then - curl -fsSL "https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz" -o $(basename "https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz") - tar -C /tmp -xzf traefik*.tar.gz - mv /tmp/traefik /usr/bin/ - rm -rf traefik*.tar.gz - systemctl restart traefik.service - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP LXC" + + RELEASE=$(curl -fsSL https://api.github.com/repos/traefik/traefik/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat ~/.traefik)" ]] || [[ ! -f ~/.traefik ]]; then + msg_info "Stopping service" + systemctl stop traefik + msg_ok "Service stopped" + + fetch_and_deploy_gh_release "traefik" "traefik/traefik" "prebuild" "latest" "/usr/bin" "traefik_v*_linux_amd64.tar.gz" + + msg_info "Starting ${APP}" + systemctl start traefik + msg_ok "Started ${APP}" + + msg_ok "Successfully updated ${APP}" else msg_ok "No update required. ${APP} is already at ${RELEASE}" fi diff --git a/frontend/public/json/traefik.json b/frontend/public/json/traefik.json index 2231e12f4b..b69d7df7d5 100644 --- a/frontend/public/json/traefik.json +++ b/frontend/public/json/traefik.json @@ -9,7 +9,7 @@ "updateable": true, "privileged": false, "interface_port": 8080, - "documentation": null, + "documentation": "https://doc.traefik.io/", "website": "https://traefik.io/", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/traefik.webp", "config_path": "/etc/traefik/traefik.yaml", diff --git a/install/traefik-install.sh b/install/traefik-install.sh index 352e116e8c..665caf34be 100644 --- a/install/traefik-install.sh +++ b/install/traefik-install.sh @@ -17,15 +17,8 @@ msg_info "Installing Dependencies" $STD apt-get install -y apt-transport-https msg_ok "Installed Dependencies" -RELEASE=$(curl -fsSL https://api.github.com/repos/traefik/traefik/releases | grep -oP '"tag_name":\s*"v\K[\d.]+?(?=")' | sort -V | tail -n 1) -msg_info "Installing Traefik v${RELEASE}" +fetch_and_deploy_gh_release "traefik" "traefik/traefik" "prebuild" "latest" "/usr/bin" "traefik_v*_linux_amd64.tar.gz" mkdir -p /etc/traefik/{conf.d,ssl} -curl -fsSL "https://github.com/traefik/traefik/releases/download/v${RELEASE}/traefik_v${RELEASE}_linux_amd64.tar.gz" -o "traefik_v${RELEASE}_linux_amd64.tar.gz" -tar -C /tmp -xzf traefik*.tar.gz -mv /tmp/traefik /usr/bin/ -rm -rf traefik*.tar.gz -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed Traefik v${RELEASE}" msg_info "Creating Traefik configuration" cat </etc/traefik/traefik.yaml @@ -84,7 +77,7 @@ EOF msg_ok "Created Traefik configuration" msg_info "Creating Service" -cat </etc/systemd/system/traefik.service +cat <<'EOF' >/etc/systemd/system/traefik.service [Unit] Description=Traefik is an open-source Edge Router that makes publishing your services a fun and easy experience @@ -97,7 +90,6 @@ ExecReload=/bin/kill -USR1 \$MAINPID [Install] WantedBy=multi-user.target EOF - systemctl enable -q --now traefik msg_ok "Created Service"