Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions ct/golink.sh
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
Copy link
Member

Choose a reason for hiding this comment

The 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg_info "Stopping $APP"
msg_info "Stopping Service"

systemctl stop golink
msg_ok "Stopped $APP"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


msg_info "Updating $APP"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use a var here

Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

msg_ok "Updated $APP to ${RELEASE}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


msg_info "Starting $APP"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg_info "Starting $APP"
msg_info "Starting Service"

systemctl start golink
msg_ok "Started $APP"
Copy link
Member

Choose a reason for hiding this comment

The 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"
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use our standard ending here

44 changes: 44 additions & 0 deletions frontend/public/json/golink.json
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't they provide any docs, like a readme?
website?
github wiki?

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh you are from tailscale itself?
What an honor :)
Alright then we'll leave that as is.

"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"
}
]
}
178 changes: 178 additions & 0 deletions install/golink-install.sh
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 \
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've swapped it with a curl to a tagged release instead.

msg_ok "Cloned Golink Repository"

msg_info "Building Golink"
cd /opt/golink || exit
$STD go mod tidy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

# Clean Go cache before building to save space
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

$STD go clean -cache -modcache

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

# Build with optimizations to reduce space usage
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

# Prompt for Tailscale authentication key
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use apt -y
also add apt -y clean

msg_ok "Cleaned"