From 8cc4c5cf030d478c6865f02431482faecaf1fe87 Mon Sep 17 00:00:00 2001 From: tremor021 Date: Sat, 31 May 2025 22:20:17 +0200 Subject: [PATCH] Test tinyauth --- ct/alpine-tinyauth.sh | 58 +++++++++++++++++++++ install/alpine-tinyauth-install.sh | 82 ++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 ct/alpine-tinyauth.sh create mode 100644 install/alpine-tinyauth-install.sh diff --git a/ct/alpine-tinyauth.sh b/ct/alpine-tinyauth.sh new file mode 100644 index 0000000..2deac8f --- /dev/null +++ b/ct/alpine-tinyauth.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# 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" +var_tags="${var_tags:-alpine;auth}" +var_cpu="${var_cpu:-1}" +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}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + if [[ ! -d /opt/tinyauth ]]; then + msg_error "No ${APP} Installation Found!" + exit 1 + fi + + msg_info "Updating packages" + $STD apk -U upgrade + msg_ok "Updated packages" + + 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 + 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" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit 0 +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/alpine-tinyauth-install.sh b/install/alpine-tinyauth-install.sh new file mode 100644 index 0000000..1396dc1 --- /dev/null +++ b/install/alpine-tinyauth-install.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# 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 + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apk add --no-cache curl openssl apache2-utils +msg_ok "Installed Dependencies" + +msg_info "Installing Tinyauth" +mkdir -p /opt/tinyauth + +RELEASE=$(curl -s https://api.github.com/repos/steveiliop56/tinyauth/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +curl -fsSL "https://github.com/steveiliop56/tinyauth/releases/download/v${RELEASE}/tinyauth-amd64" -o /opt/tinyauth/tinyauth +chmod +x /opt/tinyauth/tinyauth + +PASSWORD=$(openssl rand -base64 8 | tr -dc 'a-zA-Z0-9' | head -c 8) +USER=$(htpasswd -Bbn "tinyauth" "${PASSWORD}") + +cat </opt/tinyauth/credentials.txt +Tinyauth Credentials +Username: tinyauth +Password: ${PASSWORD} +EOF + +echo "${RELEASE}" >/opt/tinyauth_version.txt +msg_ok "Installed Tinyauth" + +read -p "${TAB3}Enter your Tinyauth subdomain (e.g. https://tinyauth.example.com): " app_url + +msg_info "Creating Tinyauth Service" +SECRET=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32) + +cat </opt/tinyauth/.env +SECRET=${SECRET} +USERS=${USER} +APP_URL=${app_url} +EOF + +sed -i -e 's/\$/\$\$/g' /opt/tinyauth/.env + +cat </etc/init.d/tinyauth +#!/sbin/openrc-run +description="Tinyauth Service" + +command="/opt/tinyauth/tinyauth" +directory="/opt/tinyauth" +command_user="root" +command_background="true" +pidfile="/var/run/tinyauth.pid" + +start_pre() { + if [ -f "/opt/tinyauth/.env" ]; then + export \$(grep -v '^#' /opt/tinyauth/.env | xargs) + fi +} + +depend() { + use net +} +EOF + +chmod +x /etc/init.d/tinyauth +$STD rc-update add tinyauth default +msg_ok "Enabled Tinyauth Service" + +msg_info "Starting Tinyauth" +$STD rc-service tinyauth start +msg_ok "Started Tinyauth" + +motd_ssh +customize