|
| 1 | +#!/usr/bin/env bash |
| 2 | +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: Slaviša Arežina (tremor021) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/steveiliop56/tinyauth |
| 7 | + |
| 8 | +APP="Alpine-tinyauth" |
| 9 | +var_tags="${var_tags:-alpine;auth}" |
| 10 | +var_cpu="${var_cpu:-1}" |
| 11 | +var_ram="${var_ram:-512}" |
| 12 | +var_disk="${var_disk:-3}" |
| 13 | +var_os="${var_os:-alpine}" |
| 14 | +var_version="${var_version:-3.21}" |
| 15 | +var_unprivileged="${var_unprivileged:-1}" |
| 16 | + |
| 17 | +header_info "$APP" |
| 18 | +variables |
| 19 | +color |
| 20 | +catch_errors |
| 21 | + |
| 22 | +function update_script() { |
| 23 | + if [[ ! -d /opt/tinyauth ]]; then |
| 24 | + msg_error "No ${APP} Installation Found!" |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | + |
| 28 | + msg_info "Updating Alpine Packages" |
| 29 | + $STD apk update |
| 30 | + $STD apk upgrade |
| 31 | + msg_ok "Updated Alpine Packages" |
| 32 | + |
| 33 | + msg_info "Updating tinyauth" |
| 34 | + RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 35 | + if [ "${RELEASE}" != "$(cat /opt/tinyauth_version.txt)" ] || [ ! -f /opt/tinyauth_version.txt ]; then |
| 36 | + $STD service tinyauth stop |
| 37 | + temp_file=$(mktemp) |
| 38 | + cp /opt/tinyauth/.env /opt |
| 39 | + rm -rf /opt/tinyauth |
| 40 | + mkdir -p /opt/tinyauth |
| 41 | + curl -fsSL "https://github.com/steveiliop56/tinyauth/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" |
| 42 | + tar -xzf "$temp_file" -C /opt/tinyauth --strip-components=1 |
| 43 | + cd /opt/tinyauth/frontend |
| 44 | + $STD bun install |
| 45 | + $STD bun run build |
| 46 | + mv dist /opt/tinyauth/internal/assets/ |
| 47 | + cd /opt/tinyauth |
| 48 | + $STD go mod download |
| 49 | + CGO_ENABLED=0 go build -ldflags "-s -w" |
| 50 | + cp /opt/.env /opt/tinyauth |
| 51 | + echo "${RELEASE}" >/opt/tinyauth_version.txt |
| 52 | + rm -f "$temp_file" |
| 53 | + msg_info "Restarting tinyauth" |
| 54 | + $STD service tinyauth start |
| 55 | + msg_ok "Restarted tinyauth" |
| 56 | + msg_ok "Updated tinyauth" |
| 57 | + else |
| 58 | + msg_ok "No update required. ${APP} is already at ${RELEASE}" |
| 59 | + fi |
| 60 | + exit 0 |
| 61 | +} |
| 62 | + |
| 63 | +start |
| 64 | +build_container |
| 65 | +description |
| 66 | + |
| 67 | +msg_ok "Completed Successfully!\n" |
| 68 | +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
| 69 | +echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
| 70 | +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" |
0 commit comments