diff --git a/.github/workflows/check-node-versions.yml b/.github/workflows/check-node-versions.yml index 904765b64..7204207ef 100644 --- a/.github/workflows/check-node-versions.yml +++ b/.github/workflows/check-node-versions.yml @@ -207,8 +207,59 @@ jobs: NVMRC_NODE_MAJOR="$ver" } + # Same name in the core sense (_forge_is_script_app): case and punctuation + # ignored, equal, or one containing the other with the shorter at least 4 long. + name_matches() { + local a="${1,,}" b="${2,,}" short + a="${a//[^a-z0-9]/}" + b="${b//[^a-z0-9]/}" + [[ -n "$a" && -n "$b" ]] || return 1 + [[ "$a" == "$b" ]] && return 0 + short="$a" + ((${#b} < ${#a})) && short="$b" + ((${#short} >= 4)) || return 1 + [[ "$a" == *"$b"* || "$b" == *"$a"* ]] + } + + # The app's own repo from the GitHub calls in its scripts, for a Source line + # that names a website. Only a repo or app argument matching the script's + # name counts: discourse also deploys libvips, storyteller pulls readium/cli. + # Usage: repo_from_calls "slug" file... => sets REPLY to owner/repo or empty + repo_from_calls() { + local slug="$1" text app repo + shift + REPLY="" + text=$(cat "$@" 2>/dev/null | grep -v '^[[:space:]]*#' || true) + while read -r app repo; do + [[ -z "$repo" || "${repo,,}" == community-scripts/* ]] && continue + if name_matches "$slug" "${repo#*/}" || { [[ "$app" != "-" ]] && name_matches "$slug" "$app"; }; then + REPLY="$repo" + return + fi + done < <( + grep -oP '\b(?:fetch_and_deploy|check_for)_gh_(?:release|tag)\s+"?[^"\s]+"?\s+"?[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+' <<<"$text" | + sed -E 's/^[a-z_]+[[:space:]]+"?([^"[:space:]]+)"?[[:space:]]+"?/\1 /' || true + grep -oP '(?:get_latest_github_release\s+"?|(?> "$GITHUB_OUTPUT" # Save issue details for next step printf '%s\n' "${issue_scripts[@]}" > /tmp/drift_scripts.txt 2>/dev/null || touch /tmp/drift_scripts.txt + printf '%s\n' "${sync_scripts[@]}" > /tmp/sync_scripts.txt 2>/dev/null || touch /tmp/sync_scripts.txt # Save full report { echo "## Node.js Version Drift Report" echo "" echo "**Generated:** $(date -u +%Y-%m-%dT%H:%M:%SZ)" - echo "**Scripts checked:** $total | **With GitHub source:** $checked | **Drift detected:** $drift_count" + echo "**Scripts checked:** $total | **With GitHub source:** $checked | **Drift detected:** $drift_count | **ct/ out of step:** $sync_count" echo "" - echo "| Script | Our Version | engines.node | Dockerfile | Upstream Repo | Status |" - echo "|--------|-------------|-------------|------------|---------------|--------|" + echo "| Script | Our Version | ct/ update | engines.node | Dockerfile | Upstream Repo | Status |" + echo "|--------|-------------|------------|-------------|------------|---------------|--------|" printf '%s\n' "${report_lines[@]}" | sort } > /tmp/drift_report.md @@ -478,12 +546,21 @@ jobs: continue fi + # Without the ct/ line the bump reaches new containers only. + ct_note="" + if [[ -f "ct/${slug}.sh" && " ${changed[*]} " != *" ct/${slug}.sh "* ]]; then + ct_note="> [!WARNING] + > \`ct/${slug}.sh\` sets no Node ${our} in its update, so existing containers stay on it. Add \`NODE_VERSION=\"${upstream}\" setup_nodejs\` to the update before merging." + fi + # The test command is written here rather than left to # pr-test-command.yml: a PR opened with GITHUB_TOKEN does not start # another workflow, so that comment would never arrive. body=$(cat </dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/freescout-help-desk/freescout + +APP="FreeScout" +var_tags="${var_tags:-helpdesk;ticketing}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-6}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_arm64="${var_arm64:-yes}" +var_unprivileged="${var_unprivileged:-1}" + +export var_admin_email="${var_admin_email:-}" +export var_admin_pass="${var_admin_pass:-}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/freescout ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "freescout" "freescout-help-desk/freescout"; then + msg_info "Stopping FreeScout" + systemctl stop cron nginx php8.4-fpm + pkill -u www-data -f artisan || true + msg_ok "Stopped FreeScout" + + create_backup /opt/freescout/.env + CLEAN_INSTALL=1 CLEAN_INSTALL_KEEP="storage Modules public/modules" fetch_and_deploy_gh_release "freescout" "freescout-help-desk/freescout" "tarball" + restore_backup + + msg_info "Updating FreeScout" + cd /opt/freescout + $STD php artisan freescout:after-app-update + $STD php artisan storage:link + chown -R www-data:www-data /opt/freescout + msg_ok "Updated FreeScout" + + msg_info "Starting FreeScout" + systemctl start php8.4-fpm nginx cron + msg_ok "Started FreeScout" + 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 "${GATEWAY}${BGN}http://${IP}${CL}" +echo -e "${INFO}${YW}Admin credentials: ~/freescout.creds (inside the container)${CL}" diff --git a/ct/openviking.sh b/ct/openviking.sh new file mode 100644 index 000000000..d2af58580 --- /dev/null +++ b/ct/openviking.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Marcos Felipe (mfelipe) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/volcengine/OpenViking + +APP="OpenViking" +var_tags="${var_tags:-ai;memory;rag}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_arm64="${var_arm64:-yes}" +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/openviking ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Updating Debian Packages" + $STD apt update + $STD apt -y upgrade + msg_ok "Updated Debian Packages" + + if check_for_gh_release "openviking-server" "volcengine/OpenViking"; then + msg_info "Stopping Service" + systemctl stop openviking + msg_ok "Stopped Service" + + msg_info "Updating OpenViking" + $STD uv pip install --python /opt/openviking/bin/python --upgrade openviking + msg_ok "Updated OpenViking" + + msg_info "Starting Service" + systemctl start openviking + 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}:1933/studio${CL}" diff --git a/ct/portabase.sh b/ct/portabase.sh index a59947ed8..3178bbca6 100644 --- a/ct/portabase.sh +++ b/ct/portabase.sh @@ -78,7 +78,7 @@ EOF create_backup /opt/portabase/.env - NODE_VERSION="22" NODE_MODULE="pnpm@11.8.0" setup_nodejs + NODE_VERSION="24" NODE_MODULE="pnpm@11.8.0" setup_nodejs CLEAN_INSTALL=1 fetch_and_deploy_gh_release "portabase" "Portabase/portabase" "tarball" diff --git a/ct/t3code.sh b/ct/t3code.sh index 6499fd33e..0475eaf47 100644 --- a/ct/t3code.sh +++ b/ct/t3code.sh @@ -30,6 +30,8 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + + NODE_VERSION="26" setup_nodejs msg_info "Stopping Service" systemctl stop t3code diff --git a/install/directus-install.sh b/install/directus-install.sh index 99d1bcbf9..7824e713a 100644 --- a/install/directus-install.sh +++ b/install/directus-install.sh @@ -17,7 +17,7 @@ msg_info "Installing Dependencies" $STD apt install -y build-essential msg_ok "Installed Dependencies" -NODE_VERSION="22" setup_nodejs +NODE_VERSION="26" setup_nodejs PG_VERSION="17" setup_postgresql PG_DB_NAME="directus" PG_DB_USER="directus" setup_postgresql_db diff --git a/install/freescout-install.sh b/install/freescout-install.sh new file mode 100644 index 000000000..4ca9a3ad9 --- /dev/null +++ b/install/freescout-install.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/freescout-help-desk/freescout + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +var_admin_email="${var_admin_email:-admin@example.com}" +if [[ ! "$var_admin_email" =~ ^[^@[:space:]]+@[^@[:space:]]+\.[^@[:space:]]+$ ]]; then + msg_warn "Invalid admin email '${var_admin_email}', using admin@example.com" + var_admin_email="admin@example.com" +fi +var_admin_pass="${var_admin_pass:-$(random_password 16)}" + +msg_info "Installing Dependencies" +$STD apt install -y nginx +msg_ok "Installed Dependencies" + +setup_mariadb +MARIADB_DB_NAME="freescout" MARIADB_DB_USER="freescout" setup_mariadb_db +PHP_VERSION="8.4" PHP_FPM="YES" setup_php +fetch_and_deploy_gh_release "freescout" "freescout-help-desk/freescout" "tarball" + +msg_info "Configuring FreeScout" +cd /opt/freescout +cat </opt/freescout/.env +APP_URL=http://${LOCAL_IP} +DB_CONNECTION=mysql +DB_HOST=localhost +DB_PORT=3306 +DB_DATABASE=freescout +DB_USERNAME=freescout +DB_PASSWORD=${MARIADB_DB_PASS} +APP_KEY= +EOF +$STD php artisan key:generate --force +$STD php artisan storage:link +$STD php artisan migrate --force +$STD php artisan freescout:create-user --role=admin --firstName=Admin --lastName=FreeScout --email="$var_admin_email" --password="$var_admin_pass" --no-interaction +touch /opt/freescout/storage/.installed +$STD php artisan freescout:clear-cache +chown -R www-data:www-data /opt/freescout +cat <>~/freescout.creds + +FreeScout Admin +Email: ${var_admin_email} +Password: ${var_admin_pass} +EOF +chmod 600 ~/freescout.creds +msg_ok "Configured FreeScout" + +msg_info "Configuring Nginx" +sed -i 's/^;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/8.4/fpm/php.ini +systemctl restart php8.4-fpm +PHP_SOCK=$(get_php_fpm_socket) +cat </etc/nginx/sites-available/freescout +server { + listen 80; + listen [::]:80; + server_name _; + + root /opt/freescout/public; + index index.php index.html index.htm; + + client_max_body_size 128M; + + location / { + try_files \$uri \$uri/ /index.php?\$query_string; + } + location ~ \.php\$ { + fastcgi_split_path_info ^(.+\.php)(/.+)\$; + fastcgi_pass unix:${PHP_SOCK}; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; + include fastcgi_params; + } + location ~* ^/storage/attachment/ { + expires 1M; + access_log off; + try_files \$uri \$uri/ /index.php?\$query_string; + } + location ~* ^/(?:css|js)/.*\.(?:css|js)\$ { + expires 2d; + access_log off; + add_header Cache-Control "public, must-revalidate"; + add_header X-Content-Type-Options "nosniff"; + } + location ~* ^/storage/.*\.((?!(jpg|jpeg|jfif|pjpeg|pjp|apng|bmp|gif|ico|cur|png|tif|tiff|webp|pdf|txt|diff|patch|json|mp3|wav|ogg|wma)).)*\$ { + add_header Content-disposition "attachment; filename=\$2"; + add_header X-Content-Type-Options "nosniff"; + default_type application/octet-stream; + } + location ~* ^/(storage/|.*\.).*\$ { + expires 1M; + access_log off; + add_header Cache-Control "public"; + add_header X-Content-Type-Options "nosniff"; + } + location ~ /\. { + deny all; + } +} +EOF +nginx_enable_site "freescout" +msg_ok "Configured Nginx" + +msg_info "Setting up Cron" +cat </etc/cron.d/freescout +* * * * * www-data php /opt/freescout/artisan schedule:run >/dev/null 2>&1 +EOF +systemctl enable -q --now cron +msg_ok "Set up Cron" + +motd_ssh +customize +cleanup_lxc diff --git a/install/openviking-install.sh b/install/openviking-install.sh new file mode 100644 index 000000000..6b0760d7f --- /dev/null +++ b/install/openviking-install.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Marcos Felipe (mfelipe) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/volcengine/OpenViking + +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 openssl +msg_ok "Installed Dependencies" + +PYTHON_VERSION="3.12" setup_uv + +msg_info "Installing OpenViking" +$STD uv venv --python 3.12 /opt/openviking +$STD uv pip install --python /opt/openviking/bin/python openviking +cat <~/.openviking-server +$(get_latest_github_release "volcengine/OpenViking") +EOF +msg_ok "Installed OpenViking" + +msg_info "Configuring OpenViking" +ROOT_API_KEY=$(openssl rand -hex 32) +mkdir -p /opt/openviking_data +cat </opt/openviking_data/ov.conf +{ + "server": { + "host": "0.0.0.0", + "port": 1933, + "root_api_key": "${ROOT_API_KEY}", + "cors_origins": ["*"] + }, + "storage": { + "workspace": "/opt/openviking_data/data", + "agfs": { "backend": "local" }, + "vectordb": { "backend": "local" } + }, + "embedding": { + "dense": { + "api_base": "https://api.openai.com/v1", + "api_key": "REPLACE_WITH_YOUR_EMBEDDING_API_KEY", + "provider": "openai", + "dimension": 1536, + "model": "text-embedding-3-small" + } + }, + "vlm": { + "api_base": "https://api.openai.com/v1", + "api_key": "REPLACE_WITH_YOUR_VLM_API_KEY", + "provider": "openai", + "model": "gpt-4o" + } +} +EOF +chmod 600 /opt/openviking_data/ov.conf +msg_ok "Configured OpenViking" + +msg_info "Creating Service" +cat </etc/systemd/system/openviking.service +[Unit] +Description=OpenViking HTTP Server +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/openviking_data +Environment="OPENVIKING_CONFIG_FILE=/opt/openviking_data/ov.conf" +ExecStart=/opt/openviking/bin/openviking-server +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now openviking + +ready=0 +for _ in {1..60}; do + if curl -fsS -o /dev/null "http://127.0.0.1:1933/health"; then + ready=1 + break + fi + sleep 2 +done +if [[ "$ready" -ne 1 ]]; then + msg_warn "OpenViking did not become healthy within 120 seconds — check 'systemctl status openviking'" +fi +msg_ok "Created Service" + +msg_info "Running OpenViking Doctor" +if OPENVIKING_CONFIG_FILE=/opt/openviking_data/ov.conf /opt/openviking/bin/openviking-server doctor >/dev/null 2>&1; then + msg_ok "Doctor check passed" +else + msg_warn "Doctor check reported warnings — configure the model API keys in /opt/openviking_data/ov.conf and restart the service" +fi + +motd_ssh +customize +cleanup_lxc diff --git a/install/portabase-install.sh b/install/portabase-install.sh index 533ccc2b9..284aaf9ae 100644 --- a/install/portabase-install.sh +++ b/install/portabase-install.sh @@ -20,7 +20,7 @@ $STD apt install -y \ nginx msg_ok "Installed Dependencies" -NODE_VERSION="22" NODE_MODULE="pnpm@11.8.0" setup_nodejs +NODE_VERSION="24" NODE_MODULE="pnpm@11.8.0" setup_nodejs PG_VERSION="17" setup_postgresql PG_DB_NAME="portabase" PG_DB_USER="portabase" setup_postgresql_db diff --git a/install/t3code-install.sh b/install/t3code-install.sh index 5680d20f6..49443b87d 100644 --- a/install/t3code-install.sh +++ b/install/t3code-install.sh @@ -20,7 +20,7 @@ $STD apt install -y \ bubblewrap msg_ok "Installed Dependencies" -NODE_VERSION="24" setup_nodejs +NODE_VERSION="26" setup_nodejs msg_info "Installing T3 Code and Provider CLIs" $STD npm install -g \ diff --git a/tools/addon/wg-easy.sh b/tools/addon/wg-easy.sh new file mode 100644 index 000000000..95d85296c --- /dev/null +++ b/tools/addon/wg-easy.sh @@ -0,0 +1,196 @@ +#!/usr/bin/env bash + +# community-scripts ORG | wg-easy Addon Installer +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/wg-easy/wg-easy + +if command -v curl >/dev/null 2>&1; then + source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/core.func") + load_functions +elif command -v wget >/dev/null 2>&1; then + source <(wget -qO- "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/core.func") + load_functions +fi +source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/lib/tools.func") +source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/error_handler.func") + +color +catch_errors + +APP="wg-easy" +APP_TYPE="addon" + +header_info "$APP" +require_debian_like +confirm_not_pve_host +get_lxc_ip + +function build_wgeasy() { + cd /opt/wg-easy/src || exit + $STD pnpm install --frozen-lockfile + $STD pnpm build + mkdir -p .output/server/database + cp -r server/database/migrations .output/server/database/ +} + +function install_wgeasy() { + if [[ -d /etc/wgdashboard ]]; then + msg_error "WGDashboard is installed in this container. wg-easy and WGDashboard would both manage wg0 - install wg-easy in its own LXC." + exit 1 + fi + if [[ -f /etc/wireguard/wg0.conf ]]; then + msg_error "/etc/wireguard/wg0.conf already exists and wg-easy would overwrite it - install wg-easy in its own LXC." + exit 1 + fi + if ! ip link add wgeasy-probe type wireguard &>/dev/null; then + msg_error "wg-easy cannot create a WireGuard interface in this container." + msg_error "Load the module on the Proxmox VE host: modprobe wireguard && echo wireguard >/etc/modules-load.d/wireguard.conf" + exit 1 + fi + ip link del wgeasy-probe + + local MEM_MB + MEM_MB=$(awk '/MemTotal/ {printf "%.0f", $2/1024}' /proc/meminfo) + if ((MEM_MB < 2048)); then + msg_error "Insufficient memory: ${MEM_MB} MB detected. At least 2048 MB RAM is required to build wg-easy." + exit 1 + fi + + cat </etc/sysctl.d/99-wg-easy.conf +net.ipv4.ip_forward=1 +net.ipv6.conf.all.forwarding=1 +EOF + sysctl -q -p /etc/sysctl.d/99-wg-easy.conf &>/dev/null || true + if [[ "$(sysctl -n net.ipv4.ip_forward)" != "1" ]]; then + rm -f /etc/sysctl.d/99-wg-easy.conf + msg_error "wg-easy needs IP forwarding, but net.ipv4.ip_forward cannot be enabled in this container." + exit 1 + fi + + local DISABLE_IPV6="false" + [[ "$(cat /proc/sys/net/ipv6/conf/all/disable_ipv6 2>/dev/null)" == "0" ]] || DISABLE_IPV6="true" + if [[ "$(ip route show default | awk '{print $5; exit}')" != "eth0" ]]; then + msg_warn "The default route is not on eth0 - set the device in wg-easy under Admin > Interface after setup." + fi + + local WG_HOST ADMIN_PASS + WG_HOST=$(prompt_input_required "wg-easy endpoint (public DNS name or IP your clients connect to):" "$LOCAL_IP" 120 "var_wg_host") + [[ "$WG_HOST" == *:* && "$WG_HOST" != \[* ]] && WG_HOST="[${WG_HOST}]" + + msg_info "Installing Dependencies" + ensure_dependencies wireguard-tools iptables + msg_ok "Installed Dependencies" + + NODE_VERSION="24" NODE_MODULE="corepack" setup_nodejs + fetch_and_deploy_gh_release "wg-easy" "wg-easy/wg-easy" "tarball" + + msg_info "Building wg-easy" + build_wgeasy + mv /opt/wg-easy/src/.output /opt/wg-easy/app + msg_ok "Built wg-easy" + + msg_info "Configuring wg-easy" + ADMIN_PASS=$(random_password) + cat </opt/wg-easy/.env +PORT=51821 +HOST=0.0.0.0 +INSECURE=true +DISABLE_IPV6=${DISABLE_IPV6} +DEBUG=Server,WireGuard,Database,CMD,Firewall +INIT_ENABLED=true +INIT_USERNAME=admin +INIT_PASSWORD=${ADMIN_PASS} +INIT_HOST=${WG_HOST} +INIT_PORT=51820 +EOF + chmod 600 /opt/wg-easy/.env + cat <<'EOF' >/usr/local/bin/wg-easy-cli +#!/usr/bin/env bash +set -a +source /opt/wg-easy/.env +set +a +exec node /opt/wg-easy/app/server/cli.mjs "$@" +EOF + chmod +x /usr/local/bin/wg-easy-cli + cat </etc/systemd/system/wg-easy.service +[Unit] +Description=wg-easy +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +WorkingDirectory=/opt/wg-easy/app +EnvironmentFile=/opt/wg-easy/.env +ExecStart=/usr/bin/node server/index.mjs +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF + systemctl enable -q --now wg-easy + msg_ok "Configured wg-easy" + + echo "" + msg_ok "wg-easy is reachable at: ${BL}http://${LOCAL_IP}:51821${CL}" + echo -e "${INFO}${YW}Username:${CL} admin" + echo -e "${INFO}${YW}Password:${CL} ${ADMIN_PASS}" + echo -e "${INFO}${YW}Clients connect to ${CL}${WG_HOST}:51820/udp${YW} - forward UDP 51820 on your router to ${CL}${LOCAL_IP}${YW}, keep TCP 51821 on the LAN.${CL}" + if [[ "$WG_HOST" == "$LOCAL_IP" ]]; then + msg_warn "No public endpoint was set - change the host in wg-easy under Admin > Config before adding clients." + fi +} + +function update_wgeasy() { + if check_for_gh_release "wg-easy" "wg-easy/wg-easy"; then + NODE_VERSION="24" NODE_MODULE="corepack" setup_nodejs + CLEAN_INSTALL=1 CLEAN_INSTALL_KEEP=".env app" fetch_and_deploy_gh_release "wg-easy" "wg-easy/wg-easy" "tarball" + + msg_info "Building wg-easy" + build_wgeasy + msg_ok "Built wg-easy" + + # Swapped only after the build: the tunnel stays up meanwhile, so an update run over the VPN does not cut itself off + msg_info "Restarting wg-easy" + rm -rf /opt/wg-easy/app + mv /opt/wg-easy/src/.output /opt/wg-easy/app + systemctl restart wg-easy + msg_ok "Restarted wg-easy" + msg_ok "Updated wg-easy" + fi +} + +function uninstall_wgeasy() { + msg_info "Uninstalling wg-easy" + systemctl disable -q --now wg-easy + wg-quick down wg0 &>/dev/null || true + rm -f /etc/systemd/system/wg-easy.service /usr/local/bin/wg-easy-cli /etc/sysctl.d/99-wg-easy.conf "$HOME/.wg-easy" + systemctl daemon-reload + rm -rf /opt/wg-easy /etc/wireguard/wg-easy.db /etc/wireguard/wg0.conf + msg_ok "Uninstalled wg-easy" +} + +if [[ -f /etc/systemd/system/wg-easy.service ]]; then + if [[ "${type:-}" == "update" ]]; then + update_wgeasy + exit 0 + fi + read -r -p "${TAB}Update (1), Uninstall (2), Cancel (3)? [1/2/3]: " action || action="" + action="${action//[[:space:]]/}" + case "$action" in + 1) update_wgeasy ;; + 2) uninstall_wgeasy ;; + 3) msg_warn "No changes made to wg-easy" ;; + *) msg_error "Invalid input - no changes made to wg-easy" ;; + esac +else + read -r -p "${TAB}Install wg-easy? (y/n): " answer || answer="" + answer="${answer//[[:space:]]/}" + if [[ "${answer,,}" =~ ^(y|yes)$ ]]; then + install_wgeasy + else + msg_warn "wg-easy installation skipped" + fi +fi