Update alpine-tinyauth.sh

This commit is contained in:
CanbiZ 2025-04-28 11:20:46 +02:00
parent 75de20858d
commit e7380bd1b4

View File

@ -20,46 +20,44 @@ color
catch_errors catch_errors
function update_script() { function update_script() {
if [[ ! -d /opt/tinyauth ]]; then if [[ ! -d /opt/tinyauth ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit 1 exit 1
fi fi
msg_info "Updating Alpine Packages" msg_info "Updating Alpine Packages"
$STD apk update $STD apk update
$STD apk upgrade $STD apk upgrade
msg_ok "Updated Alpine Packages" msg_ok "Updated Alpine Packages"
msg_info "Updating tinyauth" msg_info "Updating tinyauth"
$STD service tinyauth stop RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
temp_file=$(mktemp) if [ "${RELEASE}" != "$(cat /opt/tinyauth_version.txt)" ] || [ ! -f /opt/tinyauth_version.txt ]; then
cp /opt/tinyauth/.env /opt $STD service tinyauth stop
rm -rf /opt/tinyauth temp_file=$(mktemp)
mkdir -p /opt/tinyauth cp /opt/tinyauth/.env /opt
RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') rm -rf /opt/tinyauth
if [ "${RELEASE}" != "$(cat /opt/tinyauth_version.txt)" ] || [ ! -f /opt/tinyauth_version.txt ]; then mkdir -p /opt/tinyauth
curl -fsSL "https://github.com/steveiliop56/tinyauth/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" 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 tar -xzf "$temp_file" -C /opt/tinyauth --strip-components=1
cd /opt/tinyauth/frontend cd /opt/tinyauth/frontend
$STD bun install $STD bun install
$STD bun run build $STD bun run build
mv dist /opt/tinyauth/internal/assets/ mv dist /opt/tinyauth/internal/assets/
cd /opt/tinyauth cd /opt/tinyauth
$STD go mod download $STD go mod download
CGO_ENABLED=0 go build -ldflags "-s -w" CGO_ENABLED=0 go build -ldflags "-s -w"
cp /opt/.env /opt/tinyauth cp /opt/.env /opt/tinyauth
echo "${RELEASE}" >/opt/tinyauth_version.txt echo "${RELEASE}" >/opt/tinyauth_version.txt
rm -f "$temp_file" rm -f "$temp_file"
msg_ok "Updated tinyauth" msg_info "Restarting tinyauth"
else $STD service tinyauth start
msg_ok "No update required. ${APP} is already at ${RELEASE}" msg_ok "Restarted tinyauth"
fi msg_ok "Updated tinyauth"
else
msg_info "Restarting tinyauth" msg_ok "No update required. ${APP} is already at ${RELEASE}"
$STD service tinyauth start fi
msg_ok "Restarted tinyauth" exit 0
exit 0
} }
start start