-
-
Couldn't load subscription status.
- Fork 127
Add golink LXC #906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add golink LXC #906
Changes from 2 commits
77485b9
be95777
d13aaa2
5d43941
1166770
54723fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| 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 | ||||||
| # 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the || 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" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| systemctl stop golink | ||||||
| msg_ok "Stopped $APP" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||
|
|
||||||
| msg_info "Updating $APP" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use a var here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just asking as a learning experience here as this is my first contribution to this project. Based on the other scripts in the repo, almost all of them makes use of the $APP variable which makes sense. You'd have one single place to update the app name across the whole script and it makes it more obvious for readability. I see several comments here not to use the $APP variable and suggests instead to hardcode the app name. Could I ask why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's something we have started doing recently, there were some using a var some without, to make it easier to read and more simple to debug we chose to rather not use a var here as it doesn't really add any value here. More stylistic we know, but this ensures all scripts are line. |
||||||
| $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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||
| msg_ok "Updated $APP to ${RELEASE}" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||
|
|
||||||
| msg_info "Starting $APP" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| systemctl start golink | ||||||
| msg_ok "Started $APP" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||
| msg_ok "Update Successful" | ||||||
| else | ||||||
| msg_ok "No update required. ${APP} is already up to date" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||||||
| 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}" | ||||||
|
Comment on lines
+67
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use our standard ending here |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't they provide any docs, like a readme? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Closest thing we might have is a blog but it's a pretty simple tool. For those using Tailscale already, the wiki on the GitHub repo is pretty straightforward with no fluff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohh you are from tailscale itself? |
||
| "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" | ||
SimplyMinimal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| ], | ||
| "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" | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. debian trixie (13) uses just apt as apt 3.0 updated and now has a stable CLI interface |
||
| 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 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| # Clean Go cache before building to save space | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| $STD go clean -cache -modcache | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| # Build with optimizations to reduce space usage | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| $STD go build -ldflags="-s -w" -o golink ./cmd/golink | ||
| chmod +x golink | ||
|
|
||
| # Clean up build artifacts | ||
|
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| $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 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| # Prompt for Tailscale authentication key | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to allow users to immediately authenticate and even pre-approve golink in Tailscale using a single use Auth token. It makes setup easier. Rather than remove, is there an alternative way to optionally ask users for this info? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean remove the comment? |
||
| if [[ -n "$TS_AUTHKEY" && ("$TS_AUTHKEY" =~ ^tskey-auth- || "$TS_AUTHKEY" =~ ^tskey-) ]]; then | ||
| TAILSCALE_MODE=true | ||
| cat <<EOF >/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 <<EOF >/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 <<EOF >/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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| cat <<EOF >/etc/systemd/system/golink.service | ||
| [Unit] | ||
| Description=Golink Private Shortlink Service | ||
| After=network.target | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| User=root | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default afaik |
||
| 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 | ||
|
Comment on lines
+145
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default afaik, so does not need to be added |
||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
| else | ||
| # Development mode - include dev-listen flag | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| cat <<EOF >/etc/systemd/system/golink.service | ||
| [Unit] | ||
| Description=Golink Private Shortlink Service | ||
| After=network.target | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| User=root | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| 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 | ||
|
|
||
|
Comment on lines
+166
to
+168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| [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 | ||
|
Comment on lines
+184
to
+185
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use apt -y |
||
| msg_ok "Cleaned" | ||
Uh oh!
There was an error while loading. Please reload this page.