Files
ProxmoxVE/install/openziti-controller-install.sh
T
MickLesk 3f0dd1b09b install: answer every prompt from the environment, survive a closed stdin
Every interactive prompt takes a var_<app>_<name> override and treats a
closed stdin like Enter (`|| true`), so an install keeps going after the
console that started it is gone. Values the script cannot do without end
with exit 64 and name the variable to set. Validation loops stop asking
when nobody can answer instead of spinning on an empty read.
2026-10-23 20:44:37 +02:00

63 lines
2.9 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: emoscardini
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/openziti/ziti
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing openziti"
mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://get.openziti.io/tun/package-repos.gpg | gpg --dearmor -o /usr/share/keyrings/openziti.gpg
cat <<EOF >/etc/apt/sources.list.d/openziti.sources
Types: deb
URIs: https://packages.openziti.org/zitipax-openziti-deb-stable
Suites: debian
Components: main
Signed-By: /usr/share/keyrings/openziti.gpg
EOF
apt_update_safe
$STD apt install -y openziti-controller openziti-console </dev/null
msg_ok "Installed openziti"
prompt="${var_openziti_controller_autoconfig:-}"
[[ -n "$prompt" ]] || read -r -p "${TAB3}Would you like to go through the auto configuration now? <y/N>" prompt || true
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
GEN_FQDN="controller.${LOCAL_IP}.sslip.io"
ZITI_CTRL_ADVERTISED_ADDRESS="${var_openziti_controller_fqdn:-}"
[[ -n "$ZITI_CTRL_ADVERTISED_ADDRESS" ]] || read -r -p "${TAB3}Please enter the controller FQDN [${GEN_FQDN}]: " ZITI_CTRL_ADVERTISED_ADDRESS || true
ZITI_CTRL_ADVERTISED_ADDRESS=${ZITI_CTRL_ADVERTISED_ADDRESS:-$GEN_FQDN}
ZITI_CTRL_ADVERTISED_PORT="${var_openziti_controller_port:-}"
[[ -n "$ZITI_CTRL_ADVERTISED_PORT" ]] || read -r -p "${TAB3}Please enter the controller port [1280]: " ZITI_CTRL_ADVERTISED_PORT || true
ZITI_CTRL_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT:-1280}
ZITI_USER="${var_openziti_controller_user:-}"
[[ -n "$ZITI_USER" ]] || read -r -p "${TAB3}Please enter the controller admin user [admin]: " ZITI_USER || true
ZITI_USER=${ZITI_USER:-admin}
GEN_PWD=$(head -c128 /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!@#$%^*_+~' | cut -c 1-12)
ZITI_PWD="${var_openziti_controller_password:-}"
[[ -n "$ZITI_PWD" ]] || read -r -p "${TAB3}Please enter the controller admin password [${GEN_PWD}]:" ZITI_PWD || true
ZITI_PWD=${ZITI_PWD:-$GEN_PWD}
CONFIG_FILE="/opt/openziti/etc/controller/bootstrap.env"
sed -i "s|^ZITI_CTRL_ADVERTISED_ADDRESS=.*|ZITI_CTRL_ADVERTISED_ADDRESS='${ZITI_CTRL_ADVERTISED_ADDRESS}'|" "$CONFIG_FILE"
sed -i "s|^ZITI_CTRL_ADVERTISED_PORT=.*|ZITI_CTRL_ADVERTISED_PORT='${ZITI_CTRL_ADVERTISED_PORT}'|" "$CONFIG_FILE"
sed -i "s|^ZITI_USER=.*|ZITI_USER='${ZITI_USER}'|" "$CONFIG_FILE"
sed -i "s|^ZITI_PWD=.*|ZITI_PWD='${ZITI_PWD}'|" "$CONFIG_FILE"
env VERBOSE=0 bash /opt/openziti/etc/controller/bootstrap.bash
msg_ok "Configuration Completed"
systemctl enable -q --now ziti-controller
else
systemctl enable -q ziti-controller
msg_error "Configration not provided; Please run /opt/openziti/etc/controller/bootstrap.bash to configure the controller and restart the container"
fi
motd_ssh
customize
cleanup_lxc