diff --git a/ct/alpine-tinyauth.sh b/ct/alpine-tinyauth.sh new file mode 100644 index 0000000..88452c5 --- /dev/null +++ b/ct/alpine-tinyauth.sh @@ -0,0 +1,44 @@ +#!/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) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/steveiliop56/tinyauth + +APP="tinyauth" +var_tags="alpine;auth" +var_cpu="1" +var_ram="512" +var_disk="2" +var_os="alpine" +var_version="3.21" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + msg_info "Updating Alpine Packages" + $STD apk update && apk upgrade + msg_ok "Updated Alpine Packages" + + echo "DEBUG: CT_TYPE before update_script=${CT_TYPE:-UNDEFINED}" + echo "DEBUG: var_unprivileged=${var_unprivileged:-UNDEFINED}" + + msg_info "Updating tinyauth" + $STD apk upgrade tinyauth + msg_ok "Updated tinyauth" + + msg_info "Restarting tinyauth" + $STD rc-service tinyauth restart + msg_ok "Restarted tinyauth" +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" diff --git a/install/alpine-tinyauth-install.sh b/install/alpine-tinyauth-install.sh new file mode 100644 index 0000000..d8cc796 --- /dev/null +++ b/install/alpine-tinyauth-install.sh @@ -0,0 +1,64 @@ +#!/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 \ + 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, 2, length($2)-3) }') +curl -fsSL https://github.com/steveiliop56/tinyauth/archive/refs/tags/v3.1.0.tar.gz -o $temp_file +tar -xzf $temp_file -C /opt/tinyauth --strip-components=1 +cd /opt/tinyauth/site +$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" +SECRET=$(head -c 32 /dev/urandom | xxd -p -c 32) +msg_ok "Installed tinyauth" + +msg_info "Enabling tinyauth Service" +service_path="/etc/init.d/tinyauth" + +echo '#!/sbin/openrc-run +description="tinyauth Service" + +command="/opt/tinyauth/tinyauth" +command_args="--secret=$SECRET --users=admin@example.com:$apr1$n61ztxfk$0f/uGQFxnB.FBa5cxgqNg." +command_user="root" +pidfile="/var/run/tinyauth.pid" + +depend() { + use net +}' >$service_path + +chmod +x $service_path +$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