Refactor: Traefik (#6940)

* Refactor

* typo

---------

Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com>
This commit is contained in:
Slaviša Arežina 2025-08-18 22:12:22 +02:00 committed by GitHub
parent 296f4577d0
commit 9aafb65a98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 21 deletions

View File

@ -27,16 +27,20 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi 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" 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 /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then if [[ "${RELEASE}" != "$(cat ~/.traefik)" ]] || [[ ! -f ~/.traefik ]]; 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") msg_info "Stopping service"
tar -C /tmp -xzf traefik*.tar.gz systemctl stop traefik
mv /tmp/traefik /usr/bin/ msg_ok "Service stopped"
rm -rf traefik*.tar.gz
systemctl restart traefik.service fetch_and_deploy_gh_release "traefik" "traefik/traefik" "prebuild" "latest" "/usr/bin" "traefik_v*_linux_amd64.tar.gz"
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP LXC" msg_info "Starting ${APP}"
systemctl start traefik
msg_ok "Started ${APP}"
msg_ok "Successfully updated ${APP}"
else else
msg_ok "No update required. ${APP} is already at ${RELEASE}" msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi fi

View File

@ -9,7 +9,7 @@
"updateable": true, "updateable": true,
"privileged": false, "privileged": false,
"interface_port": 8080, "interface_port": 8080,
"documentation": null, "documentation": "https://doc.traefik.io/",
"website": "https://traefik.io/", "website": "https://traefik.io/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/traefik.webp", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/traefik.webp",
"config_path": "/etc/traefik/traefik.yaml", "config_path": "/etc/traefik/traefik.yaml",

View File

@ -17,15 +17,8 @@ msg_info "Installing Dependencies"
$STD apt-get install -y apt-transport-https $STD apt-get install -y apt-transport-https
msg_ok "Installed Dependencies" 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) fetch_and_deploy_gh_release "traefik" "traefik/traefik" "prebuild" "latest" "/usr/bin" "traefik_v*_linux_amd64.tar.gz"
msg_info "Installing Traefik v${RELEASE}"
mkdir -p /etc/traefik/{conf.d,ssl} 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" msg_info "Creating Traefik configuration"
cat <<EOF >/etc/traefik/traefik.yaml cat <<EOF >/etc/traefik/traefik.yaml
@ -84,7 +77,7 @@ EOF
msg_ok "Created Traefik configuration" msg_ok "Created Traefik configuration"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/traefik.service cat <<'EOF' >/etc/systemd/system/traefik.service
[Unit] [Unit]
Description=Traefik is an open-source Edge Router that makes publishing your services a fun and easy experience 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] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now traefik systemctl enable -q --now traefik
msg_ok "Created Service" msg_ok "Created Service"