diff --git a/ct/yourls.sh b/ct/yourls.sh new file mode 100644 index 00000000..0f75bc00 --- /dev/null +++ b/ct/yourls.sh @@ -0,0 +1,66 @@ +#!/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://yourls.org/ + +APP="YOURLS" +var_tags="${var_tags:-url-shortener;php}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-512}" +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 [[ ! -f /opt/yourls/yourls-loader.php ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "yourls" "YOURLS/YOURLS"; then + msg_info "Stopping Service" + systemctl stop nginx + msg_ok "Stopped Service" + + msg_info "Backing up Configuration" + cp -r /opt/yourls/user /opt/yourls_user.bak + msg_ok "Backed up Configuration" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "yourls" "YOURLS/YOURLS" "tarball" + chown -R www-data:www-data /opt/yourls + + msg_info "Restoring Configuration" + cp -r /opt/yourls_user.bak/. /opt/yourls/user/ + rm -rf /opt/yourls_user.bak + msg_ok "Restored Configuration" + + msg_info "Starting Service" + systemctl start nginx + 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 the admin panel using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}/admin/${CL}" +echo -e "${INFO}${YW} Complete the database setup by visiting:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}/admin/install.php${CL}" diff --git a/install/yourls-install.sh b/install/yourls-install.sh new file mode 100644 index 00000000..1f6b9219 --- /dev/null +++ b/install/yourls-install.sh @@ -0,0 +1,91 @@ +#!/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://yourls.org/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y nginx +msg_ok "Installed Dependencies" + +setup_mariadb +MARIADB_DB_NAME="yourls" MARIADB_DB_USER="yourls" setup_mariadb_db +PHP_VERSION="8.3" PHP_FPM="YES" PHP_MODULE="mysql,mbstring,gd,xml,curl" setup_php + +fetch_and_deploy_gh_release "yourls" "YOURLS/YOURLS" "tarball" + +msg_info "Configuring YOURLS" +COOKIEKEY=$(openssl rand -hex 24) +YOURLS_PASS=$(openssl rand -base64 12 | tr -dc 'a-zA-Z0-9' | cut -c1-16) +cat </opt/yourls/user/config.php + '${YOURLS_PASS}', +]; +define( 'YOURLS_URL_CONVERT', 36 ); +define( 'YOURLS_DEBUG', false ); +EOF +chown -R www-data:www-data /opt/yourls +msg_ok "Configured YOURLS" + +msg_info "Configuring Nginx" +cat </etc/nginx/sites-available/yourls +server { + listen 80 default_server; + server_name _; + root /opt/yourls; + index index.php; + + location / { + try_files \$uri \$uri/ /yourls-loader.php\$is_args\$args; + } + + location ~ \.php\$ { + fastcgi_pass unix:/run/php/php8.3-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; + include fastcgi_params; + } + + location ~* \.(jpg|jpeg|gif|css|png|js|ico|woff|woff2)\$ { + access_log off; + expires max; + } + + location ~ /\.ht { + deny all; + } +} +EOF +ln -sf /etc/nginx/sites-available/yourls /etc/nginx/sites-enabled/yourls +rm -f /etc/nginx/sites-enabled/default +$STD nginx -t +systemctl enable -q --now nginx +msg_ok "Configured Nginx" + +motd_ssh +customize +cleanup_lxc + +echo -e "${TAB}${GATEWAY}${BGN}Admin URL:${CL} http://${LOCAL_IP}/admin/" +echo -e "${TAB}${GATEWAY}${BGN}Username:${CL} admin" +echo -e "${TAB}${GATEWAY}${BGN}Password:${CL} ${YOURLS_PASS}" diff --git a/json/yourls.json b/json/yourls.json new file mode 100644 index 00000000..a6fefd11 --- /dev/null +++ b/json/yourls.json @@ -0,0 +1,44 @@ +{ + "name": "YOURLS", + "slug": "yourls", + "categories": [ + 0 + ], + "date_created": "2026-03-24", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://yourls.org/", + "website": "https://yourls.org/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/yourls.webp", + "config_path": "/opt/yourls/user/config.php", + "description": "YOURLS (Your Own URL Shortener) is a set of PHP scripts that allows you to run your own URL shortener with full control over data, detailed stats, analytics, and plugin support.", + "install_methods": [ + { + "type": "default", + "script": "ct/yourls.sh", + "resources": { + "cpu": 1, + "ram": 512, + "hdd": 4, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": "admin", + "password": "Generated during install" + }, + "notes": [ + { + "text": "After installation, visit /admin/install.php once to initialize the database and complete setup.", + "type": "info" + }, + { + "text": "The admin password is shown at the end of the installation log.", + "type": "info" + } + ] +} \ No newline at end of file