Skip to content
Open
Show file tree
Hide file tree
Changes from all 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:-13}"
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}"
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",
"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": "13"
}
}
],
"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"
}
]
}
186 changes: 186 additions & 0 deletions install/golink-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#!/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 \
ca-certificates \
sqlite3
msg_ok "Installed Dependencies"

setup_go

# 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
$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

echo "v${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 <<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
cat <<EOF >/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 <<EOF >/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"