From af93928e21fd2f3358d637cb5362cb9ddf73c113 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Mon, 20 Apr 2026 13:05:27 +0200 Subject: [PATCH] add shlink --- ct/shlink.sh | 73 +++++++++++++++++++++++++++++++++++++++ install/shlink-install.sh | 68 ++++++++++++++++++++++++++++++++++++ json/shlink.json | 44 +++++++++++++++++++++++ json/slink.json | 2 +- 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 ct/shlink.sh create mode 100644 install/shlink-install.sh create mode 100644 json/shlink.json diff --git a/ct/shlink.sh b/ct/shlink.sh new file mode 100644 index 00000000..89604399 --- /dev/null +++ b/ct/shlink.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://shlink.io/ + +APP="Shlink" +var_tags="${var_tags:-url-shortener;analytics;php}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-4}" +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/shlink ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "shlink" "shlinkio/shlink"; then + msg_info "Stopping Service" + systemctl stop shlink + msg_ok "Stopped Service" + + msg_info "Backing up Data" + cp /opt/shlink/.env /opt/shlink.env.bak + cp -r /opt/shlink/data /opt/shlink_data_backup + msg_ok "Backed up Data" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "shlink" "shlinkio/shlink" "prebuild" "latest" "/opt/shlink" "shlink*_php8.5_dist.zip" + + msg_info "Restoring Data" + cp /opt/shlink.env.bak /opt/shlink/.env + rm -f /opt/shlink.env.bak + cp -r /opt/shlink_data_backup/. /opt/shlink/data + rm -rf /opt/shlink_data_backup + msg_ok "Restored Data" + + msg_info "Updating Application" + cd /opt/shlink + $STD php ./vendor/bin/rr get --no-interaction --location bin/ + chmod +x bin/rr + $STD php bin/cli db:migrate --no-interaction + msg_ok "Updated Application" + + msg_info "Starting Service" + systemctl start shlink + msg_ok "Started Service" + msg_ok "Updated successfully!" + 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} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" diff --git a/install/shlink-install.sh b/install/shlink-install.sh new file mode 100644 index 00000000..a5aa6c1d --- /dev/null +++ b/install/shlink-install.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://shlink.io/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +PHP_VERSION="8.5" setup_php +setup_mariadb +MARIADB_DB_NAME="shlink" MARIADB_DB_USER="shlink" setup_mariadb_db + +fetch_and_deploy_gh_release "shlink" "shlinkio/shlink" "prebuild" "latest" "/opt/shlink" "shlink*_php8.5_dist.zip" + +msg_info "Setting up Application" +cd /opt/shlink +$STD php ./vendor/bin/rr get --no-interaction --location bin/ +chmod +x bin/rr +chmod -R 775 data +cat </opt/shlink/.env +DEFAULT_DOMAIN=${LOCAL_IP}:8080 +IS_HTTPS_ENABLED=false +DB_DRIVER=maria +DB_NAME=${MARIADB_DB_NAME} +DB_USER=${MARIADB_DB_USER} +DB_PASSWORD=${MARIADB_DB_PASS} +DB_HOST=127.0.0.1 +DB_PORT=3306 +EOF +$STD php bin/cli db:create --no-interaction +$STD php bin/cli db:migrate --no-interaction +INITIAL_API_KEY=$($STD php bin/cli api-key:generate --name=default 2>&1 | grep -oP '[A-Za-z0-9_-]{20,}' | head -1) +if [[ -n "$INITIAL_API_KEY" ]]; then + echo "INITIAL_API_KEY=${INITIAL_API_KEY}" >>/opt/shlink/.env +fi +msg_ok "Set up Application" + +msg_info "Creating Service" +cat </etc/systemd/system/shlink.service +[Unit] +Description=Shlink URL Shortener +After=network.target mariadb.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/shlink +EnvironmentFile=/opt/shlink/.env +ExecStart=/opt/shlink/bin/rr serve -c config/roadrunner/.rr.yml +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now shlink +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc diff --git a/json/shlink.json b/json/shlink.json new file mode 100644 index 00000000..9256a40b --- /dev/null +++ b/json/shlink.json @@ -0,0 +1,44 @@ +{ + "name": "Shlink", + "slug": "shlink", + "categories": [ + 0 + ], + "date_created": "2026-04-20", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8080, + "documentation": "https://shlink.io/documentation/", + "website": "https://shlink.io/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/shlink.webp", + "description": "Shlink is a self-hosted URL shortener built in PHP that provides detailed analytics, a REST API, tags, expiration dates, and integrations via webhooks.", + "install_methods": [ + { + "type": "default", + "script": "ct/shlink.sh", + "config_path": "/opt/shlink/.env", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 4, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "The initial API key is stored in /opt/shlink/.env. You need it to connect Shlink Web Client or any API consumer.", + "type": "warning" + }, + { + "text": "Configure your short domain by editing DEFAULT_DOMAIN in /opt/shlink/.env and restarting the service.", + "type": "info" + } + ] +} \ No newline at end of file diff --git a/json/slink.json b/json/slink.json index 335fd168..337012a9 100644 --- a/json/slink.json +++ b/json/slink.json @@ -45,4 +45,4 @@ "type": "warning" } ] -} +} \ No newline at end of file