From d2e9b6152d57801d89fe5389d0b8229f9fef8906 Mon Sep 17 00:00:00 2001 From: Andrew Baumbach Date: Mon, 28 Jul 2025 15:59:36 -0400 Subject: [PATCH] chore: bring over connector scripts from main repo --- ct/twingate-connector.sh | 46 +++++++++++++ frontend/public/json/twingate-connector.json | 40 +++++++++++ install/twingate-connector-install.sh | 70 ++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 ct/twingate-connector.sh create mode 100644 frontend/public/json/twingate-connector.json create mode 100644 install/twingate-connector-install.sh diff --git a/ct/twingate-connector.sh b/ct/twingate-connector.sh new file mode 100644 index 00000000..f87be0a0 --- /dev/null +++ b/ct/twingate-connector.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: twingate-andrewb +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://www.twingate.com/docs/ + +APP="twingate-connector" +var_tags="${var_tags:-network;connector;twingate}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-2}" +var_os="${var_os:-ubuntu}" +var_version="${var_version:-22.04}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /lib/systemd/system/twingate-connector.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Updating ${APP}" + + apt update + apt install -yq twingate-connector + systemctl restart twingate-connector + + msg_ok "Updated Successfully" + exit +} + +start +build_container +description + +msg_ok "All Finished! If you need to update your access or refresh tokens, they can be found in /etc/twingate/connector.conf" diff --git a/frontend/public/json/twingate-connector.json b/frontend/public/json/twingate-connector.json new file mode 100644 index 00000000..55eeaacb --- /dev/null +++ b/frontend/public/json/twingate-connector.json @@ -0,0 +1,40 @@ +{ + "name": "twingate-connector", + "slug": "twingate-connector", + "categories": [ + 4 + ], + "date_created": "2025-07-17", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": null, + "documentation": "https://www.twingate.com/docs/", + "config_path": "/etc/twingate/connector.conf", + "website": "https://www.twingate.com", + "logo": "https://avatars.githubusercontent.com/u/97470429?s=200&v=4", + "description": "Twingate Connectors are lightweight software components that establish secure, least-privileged access between private network resources and authorized users without exposing the network to the internet. They act as outbound-only bridges between your protected resources and the Twingate infrastructure, ensuring zero-trust access without the need for a VPN.", + "install_methods": [ + { + "type": "default", + "script": "ct/twingate-connector.sh", + "resources": { + "cpu": 1, + "ram": 2048, + "hdd": 2, + "os": "Ubuntu", + "version": "22.04" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "If you need to update your access or refresh tokens, they can be found in /etc/twingate/connector.conf", + "type": "info" + } + ] +} diff --git a/install/twingate-connector-install.sh b/install/twingate-connector-install.sh new file mode 100644 index 00000000..7e82fd2f --- /dev/null +++ b/install/twingate-connector-install.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: [Andrew Baumbach] +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: [https://raw.githubusercontent.com/twingate-andrewb/ProxmoxVE] // TODO: change this + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + + +while true; do + read -rp "Please enter your access token: " access_token + if [[ -z "$access_token" ]]; then + msg_error "Access token cannot be empty. Please try again." + else + break + fi +done + +while true; do + read -rp "Please enter your refresh token: " refresh_token + if [[ -z "$refresh_token" ]]; then + msg_error "Refresh token cannot be empty. Please try again." + else + break + fi +done + +while true; do + read -rp "Please enter your network name: " network + if [[ -z "$network" ]]; then + msg_error "Network cannot be empty. Please try again." + else + break + fi +done + +msg_info "Installing Twingate Connector..." +export TWINGATE_ACCESS_TOKEN="${access_token}" +export TWINGATE_REFRESH_TOKEN="${refresh_token}" +export TWINGATE_NETWORK="${network}" +export TWINGATE_LABEL_DEPLOYED_BY="proxmox" +curl -fsSL "https://binaries.twingate.com/connector/setup.sh" | bash >> /dev/null 2>&1 +if [[ $? -ne 0 ]]; then + msg_error "Failed to set up Twingate Connector. Please double check your tokens and network name." + exit 1 +fi +msg_ok "Twingate Connector installed!" + +msg_info "Starting Twingate Connector..." +# give the connector time to start +sleep 5s +msg_ok "Twingate Connector started!" + +echo -e "${INFO}${YW} Twingate Connector status: $(systemctl status twingate-connector) ${CL}" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Done cleaning up"