Alpine tinyauth draft

This commit is contained in:
tremor021 2025-03-25 20:34:51 +01:00
parent f9f484235d
commit 0c805d8a25
2 changed files with 108 additions and 0 deletions

44
ct/alpine-tinyauth.sh Normal file
View File

@ -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"

View File

@ -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