From 77485b90a6211d54d7bdf1924ec2804439ed07ff Mon Sep 17 00:00:00 2001 From: SimplyMinimal Date: Wed, 17 Sep 2025 23:50:42 -0400 Subject: [PATCH 1/5] Add golink LXC --- ct/golink.sh | 71 ++++++++++++ frontend/public/json/golink.json | 44 ++++++++ install/golink-install.sh | 178 +++++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+) create mode 100644 ct/golink.sh create mode 100644 frontend/public/json/golink.json create mode 100644 install/golink-install.sh diff --git a/ct/golink.sh b/ct/golink.sh new file mode 100644 index 000000000..dcf9f2355 --- /dev/null +++ b/ct/golink.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: SimplyMinimal +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/tailscale/golink + +APP="Golink" +var_tags="${var_tags:-shortlink;tailscale}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-512}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/golink ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Checking for updates" + cd /opt/golink || exit + $STD git fetch origin + CURRENT_COMMIT=$(git rev-parse HEAD) + LATEST_COMMIT=$(git rev-parse origin/main) + + if [[ "$CURRENT_COMMIT" != "$LATEST_COMMIT" ]]; then + msg_info "Stopping $APP" + systemctl stop golink + msg_ok "Stopped $APP" + + msg_info "Updating $APP" + $STD git reset --hard origin/main + $STD go mod tidy + $STD go build -o golink ./cmd/golink + chmod +x golink + RELEASE=$(git describe --tags --always 2>/dev/null || echo "main-$(git rev-parse --short HEAD)") + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to ${RELEASE}" + + msg_info "Starting $APP" + systemctl start golink + msg_ok "Started $APP" + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already up to date" + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Configuration details saved to ~/golink.creds${CL}" +echo -e "${INFO}${YW} Default access (development mode):${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" +echo -e "${INFO}${YW} For Tailscale access: Configure TS_AUTHKEY in /opt/golink/.env${CL}" diff --git a/frontend/public/json/golink.json b/frontend/public/json/golink.json new file mode 100644 index 000000000..6108d327d --- /dev/null +++ b/frontend/public/json/golink.json @@ -0,0 +1,44 @@ +{ + "name": "golink", + "slug": "golink", + "categories": [ + 4 + ], + "date_created": "2025-09-17", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8080, + "documentation": "https://github.com/tailscale/golink", + "website": "https://github.com/tailscale/golink", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/tailscale.webp", + "config_path": "/opt/golink/.env", + "description": "Golink is a private shortlink service for your tailnet. It lets you create short, memorable links that redirect to any URL of your choice.", + "install_methods": [ + { + "type": "default", + "script": "ct/golink.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 8, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "Configuration details saved to ~/golink.creds", + "type": "info" + }, + { + "text": "For Tailscale integration, configure TS_AUTHKEY in /opt/golink/.env", + "type": "info" + } + ] +} diff --git a/install/golink-install.sh b/install/golink-install.sh new file mode 100644 index 000000000..e2f716ddb --- /dev/null +++ b/install/golink-install.sh @@ -0,0 +1,178 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: SimplyMinimal +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/tailscale/golink + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + git \ + ca-certificates \ + sqlite3 +msg_ok "Installed Dependencies" + +setup_go + +msg_info "Cloning Golink Repository" +$STD git clone https://github.com/tailscale/golink.git /opt/golink +msg_ok "Cloned Golink Repository" + +msg_info "Building Golink" +cd /opt/golink || exit +$STD go mod tidy + +# Clean Go cache before building to save space +$STD go clean -cache -modcache + +# Build with optimizations to reduce space usage +$STD go build -ldflags="-s -w" -o golink ./cmd/golink +chmod +x golink + +# Clean up build artifacts +$STD go clean -cache + +RELEASE=$(git describe --tags --always 2>/dev/null || echo "main-$(git rev-parse --short HEAD)") +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +msg_ok "Built Golink" + +msg_info "Configuring Golink" +mkdir -p /opt/golink/data + +# Prompt for Tailscale authentication key +echo "" +echo "Golink can run in two modes:" +echo "1. Development/Testing mode (accessible on port 8080)" +echo "2. Production mode with Tailscale (accessible via Tailscale network at http://go/)" +echo "" +read -p "Do you want to configure Tailscale integration now? (y/N): " -r +echo "" + +TAILSCALE_MODE=false +if [[ $REPLY =~ ^[Yy]$ ]]; then + read -p "Enter your Tailscale auth key (tskey-auth-* or tskey-*): " -r TS_AUTHKEY + echo "" + + # Validate the auth key format + if [[ -n "$TS_AUTHKEY" && ("$TS_AUTHKEY" =~ ^tskey-auth- || "$TS_AUTHKEY" =~ ^tskey-) ]]; then + TAILSCALE_MODE=true + cat </opt/golink/.env +# Golink configuration with Tailscale +TS_AUTHKEY=$TS_AUTHKEY +EOF + echo "✓ Tailscale integration configured" + else + echo "⚠ Invalid auth key format. Setting up development mode instead." + echo " Auth keys should start with 'tskey-auth-' or 'tskey-'" + cat </opt/golink/.env +# Golink configuration - Development mode +# To enable Tailscale later, add your auth key here: +# TS_AUTHKEY=tskey-auth-your-key-here +EOF + fi +else + cat </opt/golink/.env +# Golink configuration - Development mode +# To enable Tailscale later, add your auth key here: +# TS_AUTHKEY=tskey-auth-your-key-here +EOF +fi +if [[ "$TAILSCALE_MODE" == "true" ]]; then + { + echo "Golink Configuration - Tailscale Mode" + echo "====================================" + echo "Mode: Production with Tailscale integration" + echo "Access: http://go/ (via Tailscale network)" + echo "" + echo "Configuration:" + echo "- Auth key configured in /opt/golink/.env" + echo "- Service will join your Tailscale network on first start" + echo "- Database location: /opt/golink/data/golink.db" + echo "" + echo "Note: Ensure MagicDNS is enabled in your Tailscale admin panel" + echo " for easy access at http://go/" + } >~/golink.creds +else + { + echo "Golink Configuration - Development Mode" + echo "=======================================" + echo "Mode: Development/Testing (local access only)" + echo "Access: http://$(hostname -I | awk '{print $1}'):8080" + echo "" + echo "To enable Tailscale later:" + echo "1. Add TS_AUTHKEY to /opt/golink/.env" + echo "2. Edit /etc/systemd/system/golink.service" + echo "3. Remove '-dev-listen :8080' from ExecStart" + echo "4. Restart service: systemctl restart golink" + echo "" + echo "Database location: /opt/golink/data/golink.db" + } >~/golink.creds +fi +msg_ok "Configured Golink" + +msg_info "Creating Service" +if [[ "$TAILSCALE_MODE" == "true" ]]; then + # Production mode with Tailscale - no dev-listen flag + cat </etc/systemd/system/golink.service +[Unit] +Description=Golink Private Shortlink Service +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/golink +ExecStart=/opt/golink/golink -sqlitedb /opt/golink/data/golink.db +EnvironmentFile=-/opt/golink/.env +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +EOF +else + # Development mode - include dev-listen flag + cat </etc/systemd/system/golink.service +[Unit] +Description=Golink Private Shortlink Service +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/golink +ExecStart=/opt/golink/golink -sqlitedb /opt/golink/data/golink.db -dev-listen :8080 +EnvironmentFile=-/opt/golink/.env +Restart=always +RestartSec=5 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=multi-user.target +EOF +fi +systemctl enable -q --now golink +if [[ "$TAILSCALE_MODE" == "true" ]]; then + msg_ok "Created Service (Tailscale Mode)" +else + msg_ok "Created Service (Development Mode)" +fi + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" From be957778c8cd05343120385d4888903f4fbb9d00 Mon Sep 17 00:00:00 2001 From: SimplyMinimal Date: Thu, 18 Sep 2025 00:04:48 -0400 Subject: [PATCH 2/5] Point golink ct to use development build.func --- ct/golink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/golink.sh b/ct/golink.sh index dcf9f2355..23d805f82 100644 --- a/ct/golink.sh +++ b/ct/golink.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2025 community-scripts ORG # Author: SimplyMinimal # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE From d13aaa2ec251ac2068c952542debb0332f211792 Mon Sep 17 00:00:00 2001 From: SimplyMinimal Date: Thu, 18 Sep 2025 16:36:39 -0400 Subject: [PATCH 3/5] Use curl to get tagged tar.gz archive of golink --- install/golink-install.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/install/golink-install.sh b/install/golink-install.sh index e2f716ddb..67b201782 100644 --- a/install/golink-install.sh +++ b/install/golink-install.sh @@ -15,16 +15,25 @@ update_os msg_info "Installing Dependencies" $STD apt-get install -y \ - git \ ca-certificates \ sqlite3 msg_ok "Installed Dependencies" setup_go -msg_info "Cloning Golink Repository" -$STD git clone https://github.com/tailscale/golink.git /opt/golink -msg_ok "Cloned Golink Repository" +# To update: change the version below to a newer tag +RELEASE="1.0.0" + +# SPECIAL CASE: tailscale/golink repository has tags but no formal GitHub releases +# fetch_and_deploy_gh_release requires formal releases, not just tags +# Since v1.0.0 exists only as a tag, we must use direct tarball download +# This follows the same pattern as fetch_and_deploy_gh_release but for tags +msg_info "Downloading Golink v${RELEASE} source" +mkdir -p /opt/golink +cd /opt/golink || exit +# Download v1.0.0 tag tarball +$STD curl -fsSL https://github.com/tailscale/golink/archive/refs/tags/v${RELEASE}.tar.gz | tar -xz --strip-components=1 +msg_ok "Downloaded Golink v${RELEASE}" msg_info "Building Golink" cd /opt/golink || exit @@ -40,8 +49,7 @@ chmod +x golink # Clean up build artifacts $STD go clean -cache -RELEASE=$(git describe --tags --always 2>/dev/null || echo "main-$(git rev-parse --short HEAD)") -echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +echo "v${RELEASE}" >"/opt/${APPLICATION}_version.txt" msg_ok "Built Golink" msg_info "Configuring Golink" From 5d43941bcd64315b9f361b02d774c32737730b2e Mon Sep 17 00:00:00 2001 From: SimplyMinimal Date: Fri, 10 Oct 2025 21:11:36 -0400 Subject: [PATCH 4/5] Use Debian 13 --- ct/golink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/golink.sh b/ct/golink.sh index 23d805f82..7d5c2d457 100644 --- a/ct/golink.sh +++ b/ct/golink.sh @@ -11,7 +11,7 @@ var_cpu="${var_cpu:-1}" var_ram="${var_ram:-512}" var_disk="${var_disk:-8}" var_os="${var_os:-debian}" -var_version="${var_version:-12}" +var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" header_info "$APP" From 11667709e48f130b0905bc283da05613ac207bf7 Mon Sep 17 00:00:00 2001 From: SimplyMinimal Date: Sat, 11 Oct 2025 20:49:28 -0400 Subject: [PATCH 5/5] Debian 13 for golink --- frontend/public/json/golink.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/json/golink.json b/frontend/public/json/golink.json index 6108d327d..b0e378fea 100644 --- a/frontend/public/json/golink.json +++ b/frontend/public/json/golink.json @@ -23,7 +23,7 @@ "ram": 512, "hdd": 8, "os": "debian", - "version": "12" + "version": "13" } } ],