refactor: use binary and randomize credentials in tinyauth (#4632)

This commit is contained in:
Stavros
2025-05-28 15:55:14 +03:00
committed by GitHub
parent 951782d8f2
commit f0dd1c264d
3 changed files with 59 additions and 70 deletions

View File

@ -1,15 +1,15 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# Author: Slaviša Arežina (tremor021) | Co-Author: Stavros (steveiliop56)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/steveiliop56/tinyauth
APP="Alpine-tinyauth"
APP="Alpine-Tinyauth"
var_tags="${var_tags:-alpine;auth}"
var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-512}"
var_disk="${var_disk:-3}"
var_ram="${var_ram:-256}"
var_disk="${var_disk:-2}"
var_os="${var_os:-alpine}"
var_version="${var_version:-3.21}"
var_unprivileged="${var_unprivileged:-1}"
@ -25,34 +25,23 @@ function update_script() {
exit 1
fi
msg_info "Updating Alpine Packages"
msg_info "Updating packages"
$STD apk -U upgrade
msg_ok "Updated Alpine Packages"
msg_ok "Updated packages"
msg_info "Updating tinyauth"
msg_info "Updating Tinyauth"
RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [ "${RELEASE}" != "$(cat /opt/tinyauth_version.txt)" ] || [ ! -f /opt/tinyauth_version.txt ]; then
$STD service tinyauth stop
temp_file=$(mktemp)
cp /opt/tinyauth/.env /opt
rm -rf /opt/tinyauth
mkdir -p /opt/tinyauth
curl -fsSL "https://github.com/steveiliop56/tinyauth/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar -xzf "$temp_file" -C /opt/tinyauth --strip-components=1
cd /opt/tinyauth/frontend
$STD bun install
$STD bun run build
mv dist /opt/tinyauth/internal/assets/
cd /opt/tinyauth
$STD go mod download
CGO_ENABLED=0 go build -ldflags "-s -w"
cp /opt/.env /opt/tinyauth
echo "${RELEASE}" >/opt/tinyauth_version.txt
rm -f "$temp_file"
msg_info "Restarting tinyauth"
rm -f /opt/tinyauth/tinyauth
curl -fsSL "https://github.com/steveiliop56/tinyauth/releases/download/v${RELEASE}/tinyauth-amd64" -o /opt/tinyauth/tinyauth
chmod +x /opt/tinyauth/tinyauth
echo "${RELEASE}" > /opt/tinyauth_version.txt
msg_info "Restarting Tinyauth"
$STD service tinyauth start
msg_ok "Restarted tinyauth"
msg_ok "Updated tinyauth"
msg_ok "Restarted Tinyauth"
msg_ok "Updated Tinyauth"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi