From cedf5c2f1a3852a2e67696398844b2bbbc7e38ab Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 09:00:38 +0000 Subject: [PATCH] 'Add new script' --- ct/alpine-tinyauth.sh | 70 +++++++++++++++++++ frontend/public/json/alpine-tinyauth.json | 51 ++++++++++++++ install/alpine-tinyauth-install.sh | 83 +++++++++++++++++++++++ 3 files changed, 204 insertions(+) create mode 100644 ct/alpine-tinyauth.sh create mode 100644 frontend/public/json/alpine-tinyauth.json 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 000000000..fec46ba0a --- /dev/null +++ b/ct/alpine-tinyauth.sh @@ -0,0 +1,70 @@ +#!/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) +# 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:-512}" +var_disk="${var_disk:-3}" +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 Alpine Packages" + $STD apk update + $STD apk upgrade + msg_ok "Updated Alpine 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 + 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" + $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/frontend/public/json/alpine-tinyauth.json b/frontend/public/json/alpine-tinyauth.json new file mode 100644 index 000000000..e458b74ad --- /dev/null +++ b/frontend/public/json/alpine-tinyauth.json @@ -0,0 +1,51 @@ +{ + "name": "Alpine-tinyauth", + "slug": "alpine-tinyauth", + "categories": [ + 6 + ], + "date_created": "2025-04-28", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://tinyauth.app/docs/getting-started.html", + "website": "https://tinyauth.app/", + "logo": "https://raw.githubusercontent.com/steveiliop56/tinyauth/refs/heads/main/frontend/public/android-chrome-192x192.png", + "config_path": "/opt/tinyauth/.env", + "description": "Tinyauth is a simple authentication middleware that adds simple username/password login or OAuth with Google, Github and any generic provider to all of your docker apps. It is designed for traefik but it can be extended to work with all reverse proxies like caddy and nginx.", + "install_methods": [ + { + "type": "default", + "script": "ct/alpine-tinyauth.sh", + "resources": { + "cpu": 1, + "ram": 256, + "hdd": 3, + "os": "alpine", + "version": "3.21" + } + }, + { + "type": "alpine", + "script": "ct/alpine-tinyauth.sh", + "resources": { + "cpu": 1, + "ram": 256, + "hdd": 3, + "os": "alpine", + "version": "3.21" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "type": "info", + "text": "`cat ~/tinyauth.creds` to view login credentials" + } + ] +} diff --git a/install/alpine-tinyauth-install.sh b/install/alpine-tinyauth-install.sh new file mode 100644 index 000000000..5692be0a8 --- /dev/null +++ b/install/alpine-tinyauth-install.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# 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 \ + npm \ + curl \ + go +msg_ok "Installed Dependencies" + +msg_info "Installing tinyauth" +temp_file=$(mktemp) +$STD npm install -g bun +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/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" +{ + echo "tinyauth Credentials" + echo "Username: admin@example.com" + echo "Password: admin" +} >>~/tinyauth.creds +echo "${RELEASE}" >/opt/tinyauth_version.txt +msg_ok "Installed tinyauth" + +msg_info "Enabling tinyauth Service" +SECRET=$(head -c 16 /dev/urandom | xxd -p -c 16 | tr -d '\n') +{ + echo "SECRET=${SECRET}" + echo "USERS=admin@example.com:\$2a\$10\$CrTK.W7WXSClo3ZY1yJUFupg5UdV8WNcynEhZhJFNjhGQB.Ga0ZDm" + echo "APP_URL=http://localhost:3000" +} >>/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 service tinyauth start +msg_ok "Started tinyauth" + +motd_ssh +customize