Files
ProxmoxVE/install/twingate-connector-install.sh
T
CanbiZ (MickLesk) 54c8b2393e install: answer every prompt from the environment, survive a closed stdin (#18121)
* 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.

* mongodb, paperless-gpt: accept yes as well as y
2026-10-24 17:55:50 +02:00

58 lines
2.1 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ), twingate-andrewb
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.twingate.com/docs/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
install -d -m 0700 /etc/twingate
access_token="${var_twingate_connector_access_token:-}"
refresh_token="${var_twingate_connector_refresh_token:-}"
network="${var_twingate_connector_network:-}"
while [[ -z "$access_token" ]]; do
read -rp "${TAB3}Please enter your access token: " access_token || { msg_error "No access token given; set var_twingate_connector_access_token or answer the prompt"; exit 64; }
done
while [[ -z "$refresh_token" ]]; do
read -rp "${TAB3}Please enter your refresh token: " refresh_token || { msg_error "No refresh token given; set var_twingate_connector_refresh_token or answer the prompt"; exit 64; }
done
while [[ -z "$network" ]]; do
read -rp "${TAB3}Please enter your network name: " network || { msg_error "No network name given; set var_twingate_connector_network or answer the prompt"; exit 64; }
done
msg_info "Setup Twingate Repository"
curl -fsSL "https://packages.twingate.com/apt/gpg.key" | gpg --dearmor -o /usr/share/keyrings/twingate-connector-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/twingate-connector-keyring.gpg] https://packages.twingate.com/apt/ /" >/etc/apt/sources.list.d/twingate.list
apt_update_safe
msg_ok "Setup Twingate Repository"
msg_info "Setup Twingate Connector"
$STD apt install -y twingate-connector
msg_ok "Setup Twingate Connector"
msg_info "Configure Twingate-Connector"
cat <<EOF >/etc/twingate/connector.conf
TWINGATE_NETWORK=${network}
TWINGATE_ACCESS_TOKEN=${access_token}
TWINGATE_REFRESH_TOKEN=${refresh_token}
TWINGATE_LABEL_HOSTNAME=$(hostname)
TWINGATE_LABEL_DEPLOYED_BY=proxmox
EOF
chmod 600 /etc/twingate/connector.conf
msg_ok "Configured Twingate-Connector"
msg_info "Starting Service"
systemctl enable -q --now twingate-connector
msg_ok "Service started"
motd_ssh
customize
cleanup_lxc