-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathalias-sites.sh
More file actions
133 lines (111 loc) · 4.63 KB
/
Copy pathalias-sites.sh
File metadata and controls
133 lines (111 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
#----------------------------------------------------------------------------------
# EngineScript - A High-Performance WordPress Server Built on Ubuntu and Cloudflare
#----------------------------------------------------------------------------------
# Website: https://EngineScript.com
# GitHub: https://github.com/Enginescript/EngineScript
# License: GPL v3.0
#----------------------------------------------------------------------------------
# EngineScript Variables
source /usr/local/bin/enginescript/enginescript-variables.txt || { echo "Error: Failed to source /usr/local/bin/enginescript/enginescript-variables.txt" >&2; exit 1; }
source /home/EngineScript/enginescript-install-options.txt || { echo "Error: Failed to source /home/EngineScript/enginescript-install-options.txt" >&2; exit 1; }
# Source shared functions library
source /usr/local/bin/enginescript/scripts/functions/shared/enginescript-common.sh || { echo "Error: Failed to source /usr/local/bin/enginescript/scripts/functions/shared/enginescript-common.sh" >&2; exit 1; }
#----------------------------------------------------------------------------------
# Start Main Script
# Terminal colors for better readability
if command -v tput > /dev/null; then
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
BLUE=$(tput setaf 4)
else
# Fallback if tput is not available
BOLD=""
NORMAL=""
GREEN=""
YELLOW=""
RED=""
BLUE=""
fi
# Header
echo -e "\n${BOLD}WordPress Sites on this Server${NORMAL}"
echo -e "================================\n"
# Check if sites configuration file exists
sites_config_file="/home/EngineScript/sites-list/sites.sh"
if [[ ! -f "$sites_config_file" ]]; then
echo "${RED}Sites configuration file not found: $sites_config_file${NORMAL}"
echo "This typically means no WordPress sites have been installed yet."
echo ""
echo "To install a new WordPress site, run: ${BOLD}es.menu${NORMAL}"
exit 0
fi
# Source the sites configuration
source "$sites_config_file"
# Initialize counters
site_count=0
# Check if SITES array exists and has content
if [[ ! -v SITES ]] || [[ ${#SITES[@]} -eq 0 ]]; then
echo "${YELLOW}No WordPress sites configured on this server.${NORMAL}"
echo "Sites are managed through: $sites_config_file"
echo ""
echo "To install a new WordPress site, run: ${BOLD}es.menu${NORMAL}"
exit 0
fi
# Count configured sites
site_count=${#SITES[@]}
# Check if any sites were found
if [[ $site_count -eq 0 ]]; then
echo "${YELLOW}No WordPress sites configured on this server.${NORMAL}"
echo "Sites are managed through: $sites_config_file"
echo ""
echo "To install a new WordPress site, run: ${BOLD}es.menu${NORMAL}"
exit 0
fi
# Display sites in a formatted table
echo "${BOLD}| # | Domain | Document Root | Status |${NORMAL}"
echo "|---|--------|---------------|--------|"
counter=1
for domain in "${SITES[@]}"; do
# Remove quotes from domain name if present
domain=$(echo "$domain" | tr -d '"')
# Construct expected site path
site_path="/var/www/sites/$domain/html"
# Validate that the site directory exists
if [[ ! -d "$site_path" ]]; then
status="${RED}✗ Missing${NORMAL}"
else
# Check if site is accessible
if curl -sL -w "%{http_code}" "https://$domain" -o /dev/null 2>/dev/null | grep -q "200"; then
status="${GREEN}✓ Online${NORMAL}"
elif curl -sL -w "%{http_code}" "http://$domain" -o /dev/null 2>/dev/null | grep -q "200"; then
status="${YELLOW}⚠ HTTP Only${NORMAL}"
else
status="${RED}✗ Offline${NORMAL}"
fi
fi
# Display site information
printf "| %2d | %-20s | %-25s | %s |\n" "$counter" "$domain" "$site_path" "$status"
((counter++))
done
echo ""
# Summary
if [[ $site_count -eq 1 ]]; then
echo "${BOLD}Found 1 WordPress site configured on this server.${NORMAL}"
else
echo "${BOLD}Found $site_count WordPress sites configured on this server.${NORMAL}"
fi
# Additional information
echo ""
echo "${BLUE}Additional Commands:${NORMAL}"
echo " ${BOLD}es.menu${NORMAL} - Access EngineScript management menu"
echo " ${BOLD}es.debug${NORMAL} - View detailed site status and server information"
echo " ${BOLD}es.info${NORMAL} - Display server information"
echo " ${BOLD}es.help${NORMAL} - Show all available commands"
echo ""
# Show sites configuration information
echo "${GREEN}✓${NORMAL} Sites are configured for automated tasks (backups, maintenance, etc.)"
echo " Configuration file: ${BOLD}$sites_config_file${NORMAL}"
echo ""