unnvense untzien
This commit is contained in:
parent
3ad92e174d
commit
c0fb6d9a32
40
ultrabunt.sh
40
ultrabunt.sh
@ -269,7 +269,8 @@ parse_arguments() {
|
|||||||
case $1 in
|
case $1 in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
# Only run main menu when executed directly (not when sourced for tests)
|
||||||
|
[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@"
|
||||||
;;
|
;;
|
||||||
-dev|--no-dev)
|
-dev|--no-dev)
|
||||||
EXCLUDED_CATEGORIES["dev"]=1
|
EXCLUDED_CATEGORIES["dev"]=1
|
||||||
@ -16616,24 +16617,22 @@ main "$@"
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
# Helper: list WordPress sites (returns array of site names)
|
# Helper: list WordPress sites (returns array of site names)
|
||||||
# Searches /var/www/* 2 levels deep for any folder that contains
|
# Searches /var/www/* 2 levels deep for any folder that contains wp-config.php
|
||||||
# wp-config.php plus a couple of other core files to avoid false positives.
|
|
||||||
__wp_sites() {
|
__wp_sites() {
|
||||||
local sites=()
|
local sites=() base="/var/www"
|
||||||
local base="/var/www"
|
|
||||||
[[ -d $base ]] || return 0
|
[[ -d $base ]] || return 0
|
||||||
|
|
||||||
# use find with maxdepth 2 – fast and safe
|
local f
|
||||||
local wp_root
|
while IFS= read -r -d '' f; do # f = …/wp-config.php
|
||||||
while IFS= read -r -d '' wp_root; do
|
local dir=${f%/*} # strip filename → directory
|
||||||
# wp_root is the directory that holds wp-config.php
|
local rel=${dir#$base/} # remove /var/www/ prefix
|
||||||
# we want the *domain* part immediately under /var/www/
|
rel=${rel%%/*} # first component = domain
|
||||||
local domain
|
[[ $rel && $rel != "." ]] && sites+=("$rel")
|
||||||
domain=$(realpath --relative-to="$base" "$wp_root" 2>/dev/null | cut -d/ -f1)
|
done < <(find "$base" -maxdepth 3 -type f -name wp-config.php -print0 2>/dev/null)
|
||||||
[[ -n $domain && $domain != "." ]] && sites+=("$domain")
|
|
||||||
done < <(find "$base" -maxdepth 2 -type f -name wp-config.php -print0 2>/dev/null | xargs -0 -I{} dirname {} | sort -u -z)
|
|
||||||
|
|
||||||
printf '%s\n' "${sites[@]}"
|
# de-duplicate
|
||||||
|
((${#sites[@]})) && mapfile -t sites < <(printf "%s\n" "${sites[@]}" | sort -u)
|
||||||
|
printf "%s\n" "${sites[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper: returns 0 if the site appears to be Internet-facing (has real DNS)
|
# Helper: returns 0 if the site appears to be Internet-facing (has real DNS)
|
||||||
@ -16650,9 +16649,16 @@ __site_is_live() {
|
|||||||
# Menu entry point
|
# Menu entry point
|
||||||
show_reverse_proxy_addons_menu() {
|
show_reverse_proxy_addons_menu() {
|
||||||
log "Reverse-Proxy & Add-ons menu opened"
|
log "Reverse-Proxy & Add-ons menu opened"
|
||||||
|
|
||||||
|
# ---- extra safety: ensure we never call ui_menu with zero items ----
|
||||||
|
local wp; mapfile -t wp < <(__wp_sites)
|
||||||
|
if [[ ${#wp[@]} -eq 0 ]]; then
|
||||||
|
ui_msg "No WordPress sites" "No WordPress installations detected in /var/www.\n\nPlease install WordPress first."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
local wp
|
|
||||||
mapfile -t wp < <(__wp_sites)
|
|
||||||
local info="Reverse-Proxy & Add-ons\n\n"
|
local info="Reverse-Proxy & Add-ons\n\n"
|
||||||
if [[ ${#wp[@]} -eq 0 ]]; then
|
if [[ ${#wp[@]} -eq 0 ]]; then
|
||||||
info+="❌ No WordPress sites found.\n Please install WordPress first.\n"
|
info+="❌ No WordPress sites found.\n Please install WordPress first.\n"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user