|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: emoscardini |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/openziti/ziti |
| 7 | + |
| 8 | +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" |
| 9 | +color |
| 10 | +verb_ip6 |
| 11 | +catch_errors |
| 12 | +setting_up_container |
| 13 | +network_check |
| 14 | +update_os |
| 15 | + |
| 16 | +msg_info "Installing Dependencies" |
| 17 | +$STD apt-get install -y gpg |
| 18 | +msg_ok "Installed Dependencies" |
| 19 | + |
| 20 | +msg_info "Installing openziti" |
| 21 | +mkdir -p --mode=0755 /usr/share/keyrings |
| 22 | +curl -fsSL https://get.openziti.io/tun/package-repos.gpg | gpg --dearmor -o /usr/share/keyrings/openziti.gpg |
| 23 | +echo "deb [signed-by=/usr/share/keyrings/openziti.gpg] https://packages.openziti.org/zitipax-openziti-deb-stable debian main" >/etc/apt/sources.list.d/openziti.list |
| 24 | +$STD apt-get update |
| 25 | +$STD apt-get install -y openziti-controller openziti-console |
| 26 | +msg_ok "Installed openziti" |
| 27 | + |
| 28 | +read -r -p "Would you like to go through the auto configuration now? <y/N>" prompt |
| 29 | +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then |
| 30 | + IPADDRESS=$(hostname -I | awk '{print $1}') |
| 31 | + GEN_FQDN="controller.${IPADDRESS}.sslip.io" |
| 32 | + read -r -p "Please enter the controller FQDN [${GEN_FQDN}]: " ZITI_CTRL_ADVERTISED_ADDRESS |
| 33 | + ZITI_CTRL_ADVERTISED_ADDRESS=${ZITI_CTRL_ADVERTISED_ADDRESS:-$GEN_FQDN} |
| 34 | + read -r -p "Please enter the controller port [1280]: " ZITI_CTRL_ADVERTISED_PORT |
| 35 | + ZITI_CTRL_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT:-1280} |
| 36 | + read -r -p "Please enter the controller admin user [admin]: " ZITI_USER |
| 37 | + ZITI_USER=${ZITI_USER:-admin} |
| 38 | + GEN_PWD=$(head -c128 /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!@#$%^*_+~' | cut -c 1-12) |
| 39 | + read -r -p "Please enter the controller admin password [${GEN_PWD}]:" ZITI_PWD |
| 40 | + ZITI_PWD=${ZITI_PWD:-$GEN_PWD} |
| 41 | + CONFIG_FILE="/opt/openziti/etc/controller/bootstrap.env" |
| 42 | + sed -i "s|^ZITI_CTRL_ADVERTISED_ADDRESS=.*|ZITI_CTRL_ADVERTISED_ADDRESS='${ZITI_CTRL_ADVERTISED_ADDRESS}'|" "$CONFIG_FILE" |
| 43 | + sed -i "s|^ZITI_CTRL_ADVERTISED_PORT=.*|ZITI_CTRL_ADVERTISED_PORT='${ZITI_CTRL_ADVERTISED_PORT}'|" "$CONFIG_FILE" |
| 44 | + sed -i "s|^ZITI_USER=.*|ZITI_USER='${ZITI_USER}'|" "$CONFIG_FILE" |
| 45 | + sed -i "s|^ZITI_PWD=.*|ZITI_PWD='${ZITI_PWD}'|" "$CONFIG_FILE" |
| 46 | + env VERBOSE=0 bash /opt/openziti/etc/controller/bootstrap.bash |
| 47 | + msg_ok "Configuration Completed" |
| 48 | + systemctl enable -q --now ziti-controller |
| 49 | +else |
| 50 | + systemctl enable -q ziti-controller |
| 51 | + msg_error "Configration not provided; Please run /opt/openziti/etc/controller/bootstrap.bash to configure the controller and restart the container" |
| 52 | +fi |
| 53 | + |
| 54 | +motd_ssh |
| 55 | +customize |
| 56 | + |
| 57 | +msg_info "Cleaning up" |
| 58 | +$STD apt-get -y autoremove |
| 59 | +$STD apt-get -y autoclean |
| 60 | +msg_ok "Cleaned" |
0 commit comments