diff --git a/ct/komodo-periphery.sh b/ct/komodo-periphery.sh new file mode 100644 index 0000000000..52cc5e0f71 --- /dev/null +++ b/ct/komodo-periphery.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +_CS_DEFAULT_URL="https://raw.githubusercontent.com/community-scripts/DevScripts/main" +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +# shellcheck source=/dev/null +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") + +# Copyright (c) 2026 community-scripts ORG +# Author: Sofiane A. (soflane) +# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE +# Source: https://komo.do/ | https://github.com/moghtech/komodo + +APP="Komodo-Periphery" +var_tags="${var_tags:-docker;komodo}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" +#var_arm64="${var_arm64:-no}" # unset = ask the user; set yes/no only when verified + +export var_komodo_core_address="${var_komodo_core_address:-}" +export var_komodo_server_name="${var_komodo_server_name:-}" +export var_komodo_onboarding_key="${var_komodo_onboarding_key:-}" +export var_komodo_core_public_key="${var_komodo_core_public_key:-}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -x /opt/komodo-periphery/periphery || ! -f /etc/komodo/periphery.config.json ]]; then + msg_error "No Komodo Periphery installation found!" + exit 233 + fi + + if ! var_komodo_addon_script="$(_cs_fetch_text "tools/addon/komodo-periphery.sh")" || + [[ -z "$var_komodo_addon_script" ]]; then + msg_error "Could not load the Komodo Periphery addon." + exit 115 + fi + mkdir -p /usr/local/lib/komodo-periphery + addon_file=$(mktemp /usr/local/lib/komodo-periphery/.addon.XXXXXX) + cat <"$addon_file" +$var_komodo_addon_script +EOF + chmod 755 "$addon_file" + mv -f "$addon_file" /usr/local/lib/komodo-periphery/addon.sh + type=update bash /usr/local/lib/komodo-periphery/addon.sh + exit +} + +if on_pve_host; then + root_check + if is_unattended && [[ -z "$var_komodo_core_address" || -z "$var_komodo_onboarding_key" ]]; then + msg_error "Supply var_komodo_core_address and var_komodo_onboarding_key before creating the Komodo Periphery LXC." + exit 1 + fi + var_komodo_core_address=$(prompt_input_required "Komodo Core URL:" "" 120 "var_komodo_core_address") + if [[ ! "$var_komodo_core_address" =~ ^https?://[^[:space:]/]+(/[^[:space:]]*)?$ ]]; then + msg_error "Komodo Periphery requires an HTTP or HTTPS Core URL without whitespace." + exit 1 + fi + if [[ -z "$var_komodo_onboarding_key" ]] && ! is_unattended; then + read -r -s -p "${TAB3}Komodo Server Onboarding Key: " var_komodo_onboarding_key /usr/local/lib/komodo-periphery/addon.sh +$var_komodo_addon_script +EOF +chmod 755 /usr/local/lib/komodo-periphery/addon.sh +msg_ok "Prepared Komodo Periphery installer" + +# The CT creation wizard authorizes Docker installation in this new guest. +var_komodo_setup_docker=yes bash /usr/local/lib/komodo-periphery/addon.sh +unset var_komodo_addon_script var_komodo_onboarding_key + +motd_ssh +customize +cleanup_lxc diff --git a/json/komodo-periphery.json b/json/komodo-periphery.json new file mode 100644 index 0000000000..02cac06102 --- /dev/null +++ b/json/komodo-periphery.json @@ -0,0 +1,85 @@ +{ + "name": "Komodo Periphery", + "slug": "komodo-periphery", + "categories": [ + 3 + ], + "date_created": "2026-10-14", + "type": "ct", + "updateable": true, + "privileged": false, + "platforms": [ + "pve" + ], + "interface_port": null, + "documentation": "https://komo.do/docs/setup/connect-servers", + "website": "https://komo.do/", + "repository": "https://github.com/moghtech/komodo", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/komodo.webp", + "description": "A Docker LXC with the native Komodo Periphery agent, connecting to an existing Core for centralized container and Compose stack management.", + "install_methods": [ + { + "type": "default", + "script": "ct/komodo-periphery.sh", + "config_path": "/etc/komodo/periphery.config.json", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 8, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "app_vars": [ + { + "name": "var_komodo_core_address", + "label": "Komodo Core URL", + "type": "text", + "required": true, + "help": "Reachable HTTP or HTTPS Core URL, such as https://komodo.example.com." + }, + { + "name": "var_komodo_server_name", + "label": "Komodo Server Name", + "type": "text", + "help": "Server name in Core; defaults to the guest hostname." + }, + { + "name": "var_komodo_onboarding_key", + "label": "Server Onboarding Key", + "type": "password", + "secret": true, + "required": true, + "help": "Create a Server Onboarding Key in Komodo Core before installation." + }, + { + "name": "var_komodo_core_public_key", + "label": "Core Public Key", + "type": "text", + "help": "Optional Core public key; defaults to trusting and pinning the first Core in /etc/komodo/keys/core.pub." + } + ], + "notes": [ + { + "text": "Run the CT creator on Proxmox VE. It creates a Debian LXC, installs Docker/Compose and runs Periphery natively under systemd.", + "type": "info" + }, + { + "text": "Create an onboarding key in Core before installation, then confirm the server is connected. See the linked documentation for onboarding and authentication.", + "type": "info" + }, + { + "text": "Run update_komodo_periphery for the latest stable agent. Configuration, keys and stack data are retained under /etc/komodo; the guest's existing update command is preserved.", + "type": "info" + }, + { + "text": "ARM64 has not been tested. The installer asks for confirmation before attempting it.", + "type": "warning" + } + ] +} diff --git a/tools/addon/komodo-periphery.sh b/tools/addon/komodo-periphery.sh new file mode 100644 index 0000000000..d309629725 --- /dev/null +++ b/tools/addon/komodo-periphery.sh @@ -0,0 +1,213 @@ +#!/usr/bin/env bash + +# Copyright (c) 2026 community-scripts ORG +# Author: Sofiane A. (soflane) +# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE +# Source: https://komo.do/ | https://github.com/moghtech/komodo + +for _cs_file in core/core.func lib/tools.func core/error_handler.func; do + if [[ -n "${COMMUNITY_SCRIPTS_CORE_DIR:-}" && -f "${COMMUNITY_SCRIPTS_CORE_DIR}/${_cs_file}" ]]; then + # shellcheck source=/dev/null + source "${COMMUNITY_SCRIPTS_CORE_DIR}/${_cs_file}" + else + # shellcheck source=/dev/null + source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/${_cs_file}") + fi +done + +APP="Komodo Periphery" +export APP_TYPE="addon" +NSAPP="komodo-periphery" +BACKUP_DIR="/opt/${NSAPP}.backup" +INSTALL_PATH="/opt/komodo-periphery" +CONFIG_PATH="/etc/komodo/periphery.config.json" +COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://raw.githubusercontent.com/community-scripts/DevScripts/main}" + +load_functions +catch_errors +header_info "$APP" + +root_check +if on_pve_host; then + msg_error "Run the Komodo Periphery addon inside an LXC or VM, not on the Proxmox VE host." + exit 232 +fi +require_debian_like +if [[ ! -d /run/systemd/system ]]; then + msg_error "Komodo Periphery requires a running systemd instance." + exit 238 +fi +arch_check + +case "${type:-install}" in +install | update) ;; +*) + msg_error "Komodo Periphery supports type=install or type=update." + exit 1 + ;; +esac + +if [[ -x "${INSTALL_PATH}/periphery" && -f "$CONFIG_PATH" && -f /etc/systemd/system/periphery.service ]] && + grep -qxF "ExecStart=${INSTALL_PATH}/periphery --config-path ${CONFIG_PATH}" /etc/systemd/system/periphery.service; then + type=update +elif [[ "${type:-}" == "update" || -e "$INSTALL_PATH" || -e "$CONFIG_PATH" || + -e /etc/komodo/periphery.config.toml || -e /etc/komodo/keys/periphery.key || + -e /etc/systemd/system/periphery.service ]]; then + msg_error "Komodo Periphery installation is missing, incomplete or managed by another installer." + exit 233 +else + type=install +fi + +if [[ "$type" == "install" ]]; then + if is_unattended && [[ -z "${var_komodo_core_address:-}" || -z "${var_komodo_onboarding_key:-}" ]]; then + msg_error "Supply var_komodo_core_address and var_komodo_onboarding_key for unattended Komodo Periphery installation." + exit 1 + fi + var_komodo_core_address=$(prompt_input_required "Komodo Core URL:" "" 120 "var_komodo_core_address") + if [[ ! "$var_komodo_core_address" =~ ^https?://[^[:space:]/]+(/[^[:space:]]*)?$ ]]; then + msg_error "Komodo Periphery requires an HTTP or HTTPS Core URL without whitespace." + exit 1 + fi + var_komodo_server_name=$(prompt_input_required "Komodo server name:" "$(hostname)" 120 "var_komodo_server_name") + if [[ -z "${var_komodo_onboarding_key:-}" ]] && ! is_unattended; then + read -r -s -p "${TAB3}Komodo Server Onboarding Key: " var_komodo_onboarding_key "$config_file" + chmod 600 "$config_file" + mv -f "$config_file" "$CONFIG_PATH" + unset var_komodo_onboarding_key + msg_ok "Configured Komodo Periphery" + + msg_info "Creating Komodo Periphery service" + cat <<'EOF' >/etc/systemd/system/periphery.service +[Unit] +Description=Komodo Periphery agent +Documentation=https://komo.do/docs/setup/connect-servers +Wants=network-online.target +After=network-online.target docker.service +Requires=docker.service + +[Service] +Type=simple +User=root +Environment=HOME=/root +WorkingDirectory=/etc/komodo +ExecStart=/opt/komodo-periphery/periphery --config-path /etc/komodo/periphery.config.json +Restart=on-failure +RestartSec=5 +UMask=0077 + +[Install] +WantedBy=multi-user.target +EOF + systemctl enable -q --now periphery + sleep 2 + $STD systemctl is-active --quiet periphery + msg_ok "Created Komodo Periphery service" +fi + +msg_info "Creating Komodo Periphery update command" +printf -v scripts_url '%q' "$COMMUNITY_SCRIPTS_URL" +printf -v core_url '%q' "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}" +update_file=$(mktemp /usr/local/bin/.update_komodo_periphery.XXXXXX) +cat <"$update_file" +#!/usr/bin/env bash +set -Eeuo pipefail +export COMMUNITY_SCRIPTS_URL=${scripts_url} +export COMMUNITY_SCRIPTS_CORE_URL=${core_url} +if [[ -f /usr/local/lib/komodo-periphery/addon.sh ]]; then + type=update bash /usr/local/lib/komodo-periphery/addon.sh +else + addon_script=\$(curl -fsSL "\$COMMUNITY_SCRIPTS_URL/tools/addon/komodo-periphery.sh") + type=update bash -c "\$addon_script" +fi +EOF +chmod 755 "$update_file" +mv -f "$update_file" /usr/local/bin/update_komodo_periphery +rm -f "${INSTALL_PATH}/version-policy" +msg_ok "Created Komodo Periphery update command" +msg_ok "Komodo Periphery setup completed" +echo -e "${INFO}Confirm the server connection in Komodo Core; check journalctl -u periphery if needed."