Headscale: Add headscale-admin UI as option (#6205)

This commit is contained in:
Slaviša Arežina 2025-07-24 21:00:13 +02:00 committed by GitHub
parent eda1b1aea8
commit e25f3dce52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 0 deletions

View File

@ -38,6 +38,7 @@ function update_script() {
msg_ok "Stopped ${APP}" msg_ok "Stopped ${APP}"
fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary" fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary"
fetch_and_deploy_gh_release "headscale-admin" "GoodiesHQ/headscale-admin" "prebuild" "latest" "/opt/headscale-admin" "admin.zip"
msg_info "Starting ${APP}" msg_info "Starting ${APP}"
# Temporary fix until headscale project resolves service getting disabled on updates. # Temporary fix until headscale project resolves service getting disabled on updates.

View File

@ -35,6 +35,10 @@
{ {
"text": "Configuration settings: `/etc/headscale/config.yaml`", "text": "Configuration settings: `/etc/headscale/config.yaml`",
"type": "info" "type": "info"
},
{
"text": "Access headscale-admin UI via `http://<LXC-IP>/admin/`",
"type": "info"
} }
] ]
} }

View File

@ -15,6 +15,43 @@ update_os
fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary" fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary"
read -r -p "${TAB3}Would you like to add headscale-admin UI? <y/N> " prompt
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
fetch_and_deploy_gh_release "headscale-admin" "GoodiesHQ/headscale-admin" "prebuild" "latest" "/opt/headscale-admin" "admin.zip"
msg_info "Configuring headscale-admin"
$STD apt-get install -y caddy
$STD caddy stop
rm /etc/caddy/Caddyfile
cat <<EOF >/etc/caddy/Caddyfile
:{$PORT:80}
handle_path /admin* {
root * /opt/headscale-admin
encode gzip zstd
# Correct MIME types for JS/WASM
header {
@js_files path *.js
@wasm_files path *.wasm
Content-Type @js_files application/javascript
Content-Type @wasm_files application/wasm
X-Content-Type-Options nosniff
}
# Fallback for SPA routing
try_files {path} {path}/ index.html
file_server
}
EOF
caddy fmt --overwrite /etc/caddy/Caddyfile
systemctl start caddy
msg_ok "Configured headscale-admin"
fi
msg_info "Starting service" msg_info "Starting service"
systemctl enable -q --now headscale systemctl enable -q --now headscale
msg_ok "Service started" msg_ok "Service started"