diff --git a/scripts/pma-gateway/create_pma_gateway.sh b/scripts/pma-gateway/create_pma_gateway.sh index 0acfd82..374d9ca 100644 --- a/scripts/pma-gateway/create_pma_gateway.sh +++ b/scripts/pma-gateway/create_pma_gateway.sh @@ -53,6 +53,95 @@ token="$base.$mac" # Secure the phpMyAdmin vhost with Rewrite Rules to block direct access VHOST_CONFIG="/usr/share/phpMyAdmin/vhost.conf" NEEDS_RESTART=0 + +# If vhost config is missing or empty, recreate it from a known-good default. +if [ ! -s "$VHOST_CONFIG" ]; then + echo "Warning: $VHOST_CONFIG is empty or missing. Recreating from default." >&2 + sudo tee "$VHOST_CONFIG" > /dev/null <<'EOF' + + + /usr/share/phpMyAdmin/ + 1 + + + 0 + $SERVER_ROOT/logs/error.log + DEBUG + 10M + + + 0 + $SERVER_ROOT/logs/access.log + 10M + 30 + 0 + + + + 0 + index.php, index.html + 0 + /_autoindex/default.php + + + + 404 + /error404.html + + + + 31 + .htaccess + + + 1 + + + 0 + + 0 + gif, jpeg, jpg + 1 + 1 + + + * + + 10 + + + /tmp/lscache/vhosts/$VH_NAME + + + + 0 + 0 + RewriteCond %{HTTP_USER_AGENT} ^NameOfBadRobot +RewriteRule ^/nospider/ - [F] + + + /var/www/ssl/litespeed.key + /var/www/ssl/litespeed.crt + 1 + + + 0 + 0 + + + 0 + $VH_ROOT/awstats + /awstats/ + localhost + 127.0.0.1 localhost + 86400 + 0 + + +EOF + NEEDS_RESTART=1 +fi + if [ -f "$VHOST_CONFIG" ]; then MARKER="# PMA Gateway Security Rules"