From 48c7d7ee1b227caf40b3c54cbde9b242bc411da8 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:57:01 +0200 Subject: [PATCH] testing --- ct/hanko.sh | 44 +++++++++++++++++++++++++++ install/hanko-install.sh | 24 +++++++++++++++ misc/tools.func | 65 +++++++++++++++++++++++++++++++++++----- 3 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 ct/hanko.sh create mode 100644 install/hanko-install.sh diff --git a/ct/hanko.sh b/ct/hanko.sh new file mode 100644 index 00000000..00dfc558 --- /dev/null +++ b/ct/hanko.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +source <(curl -s https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) +# Copyright (c) 2021-2025 tteck +# Author: tteck (tteckster) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://www.debian.org/ + +APP="Debian" +var_tags="${var_tags:-os}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-512}" +var_disk="${var_disk:-2}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" +var_fuse="${var_fuse:-yes}" +var_tun="${var_tun:-yes}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /var ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" diff --git a/install/hanko-install.sh b/install/hanko-install.sh new file mode 100644 index 00000000..997b7cc9 --- /dev/null +++ b/install/hanko-install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 tteck +# Author: tteck (tteckster) +# License: MIT +# https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +fetch_and_deploy_gh_release "hanko" "teamhanko/hanko" "prebuild" "latest" "/opt/hanko" "hanko_Linux_x86_64.tar.gz" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/misc/tools.func b/misc/tools.func index e6a8e54f..f0c7e4aa 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -676,16 +676,33 @@ install_mongodb() { } # ------------------------------------------------------------------------------ -# Downloads and deploys latest GitHub release tarball. +# Downloads and deploys latest GitHub release (source, binary or asset tarball). # # Description: -# - Fetches latest release from GitHub API -# - Detects matching asset by architecture -# - Extracts to /opt/ and saves version +# - Fetches latest release metadata from GitHub API +# - Supports source tarball, .deb binary or prebuilt .tar.gz asset +# - Extracts or installs the release and writes version to ~/. # -# Variables: -# APP - Override default application name (optional) -# GITHUB_TOKEN - (optional) GitHub token for private rate limits +# Parameters: +# $1 APP - Application name (used for target path and version file) +# $2 REPO - GitHub repository (e.g. user/repo) +# $3 MODE - Release type: tarball | source | binary | prebuild +# $4 VERSION - Optional version tag (default: latest) +# $5 TARGET_DIR - Optional install path (default: /opt/) +# $6 ASSET_FILENAME - Required for mode=prebuild (e.g. hanko_Linux_x86_64.tar.gz) +# +# Optional: +# - Set GITHUB_TOKEN env var to increase API rate limit (esp. in CI). +# +# Examples: +# # 1. Minimal: Source tarball (default mode = tarball) +# fetch_and_deploy_gh_release "myapp" "myuser/myapp" +# +# # 2. Binary install via .deb (auto-detected by architecture) +# fetch_and_deploy_gh_release "myapp" "myuser/myapp" "binary" +# +# # 3. Prebuilt asset tar.gz (exact filename match) +# fetch_and_deploy_gh_release "hanko" "teamhanko/hanko" "prebuild" "latest" "/opt/hanko" "hanko_Linux_x86_64.tar.gz" # ------------------------------------------------------------------------------ fetch_and_deploy_gh_release() { @@ -816,6 +833,40 @@ fetch_and_deploy_gh_release() { } } + elif [[ "$mode" == "prebuild" ]]; then + local pattern="$6" + if [[ -z "$pattern" ]]; then + msg_error "Mode 'prebuild' requires 6th parameter (asset filename pattern)" + rm -rf "$tmpdir" + return 1 + fi + + local assets asset_url="" + assets=$(echo "$json" | jq -r '.assets[].browser_download_url') + for u in $assets; do + if [[ "$u" =~ $pattern || "$u" == *"$pattern" ]]; then + asset_url="$u" + break + fi + done + + if [[ -z "$asset_url" ]]; then + msg_error "No asset matching pattern '$pattern' found" + rm -rf "$tmpdir" + return 1 + fi + + filename="${asset_url##*/}" + $STD msg_info "Downloading prebuilt asset: $asset_url" + curl $curl_timeout -fsSL -o "$tmpdir/$filename" "$asset_url" || { + msg_error "Download failed: $asset_url" + rm -rf "$tmpdir" + return 1 + } + + mkdir -p "$target" + tar -xzf "$tmpdir/$filename" -C "$target" + else msg_error "Unknown mode: $mode" rm -rf "$tmpdir"