Skip to content

Commit 3bfb702

Browse files
authored
Logging and removal script improvements
1 parent 46f9ab8 commit 3bfb702

8 files changed

Lines changed: 100 additions & 51 deletions

File tree

scripts/install/enginescript-install.sh

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ if [ "$WP_ADMIN_PASSWORD" = PLACEHOLDER ];
163163
fi
164164

165165
# Install Check
166-
source /home/EngineScript/install-log.txt
166+
source /var/log/EngineScript/install-log.txt
167167

168168
# Repositories
169169
if [ "${REPOS}" = 1 ];
170170
then
171171
echo "REPOS script has already run"
172172
else
173173
/usr/local/bin/enginescript/scripts/install/repositories/repositories-install.sh
174-
echo "REPOS=1" >> /home/EngineScript/install-log.txt
174+
echo "REPOS=1" >> /var/log/EngineScript/install-log.txt
175175
fi
176176

177177
# Remove Preinstalled Software
@@ -180,7 +180,7 @@ if [ "${REMOVES}" = 1 ];
180180
echo "REMOVES script has already run"
181181
else
182182
/usr/local/bin/enginescript/scripts/install/removes/remove-preinstalled.sh
183-
echo "REMOVES=1" >> /home/EngineScript/install-log.txt
183+
echo "REMOVES=1" >> /var/log/EngineScript/install-log.txt
184184
fi
185185

186186
# Block Unwanted Packages
@@ -189,7 +189,7 @@ if [ "${BLOCK}" = 1 ];
189189
echo "BLOCK script has already run"
190190
else
191191
/usr/local/bin/enginescript/scripts/install/block/package-block.sh
192-
echo "BLOCK=1" >> /home/EngineScript/install-log.txt
192+
echo "BLOCK=1" >> /var/log/EngineScript/install-log.txt
193193
fi
194194

195195
# Enabled Ubuntu Pro Apt Updates
@@ -207,7 +207,7 @@ if [ "${DEPENDS}" = 1 ];
207207
echo "DEPENDS script has already run"
208208
else
209209
/usr/local/bin/enginescript/scripts/install/depends/depends-install.sh
210-
echo "DEPENDS=1" >> /home/EngineScript/install-log.txt
210+
echo "DEPENDS=1" >> /var/log/EngineScript/install-log.txt
211211
fi
212212

213213
# ACME.sh
@@ -216,7 +216,7 @@ if [ "${ACME}" = 1 ];
216216
echo "ACME.sh script has already run"
217217
else
218218
/usr/local/bin/enginescript/scripts/install/acme/acme-install.sh
219-
echo "ACME=1" >> /home/EngineScript/install-log.txt
219+
echo "ACME=1" >> /var/log/EngineScript/install-log.txt
220220
fi
221221

222222
# GCC
@@ -225,7 +225,7 @@ if [ "${GCC}" = 1 ];
225225
echo "GCC script has already run."
226226
else
227227
/usr/local/bin/enginescript/scripts/install/gcc/gcc-install.sh
228-
echo "GCC=1" >> /home/EngineScript/install-log.txt
228+
echo "GCC=1" >> /var/log/EngineScript/install-log.txt
229229
fi
230230

231231
# OpenSSL
@@ -234,7 +234,7 @@ if [ "${OPENSSL}" = 1 ];
234234
echo "OPENSSL script has already run."
235235
else
236236
/usr/local/bin/enginescript/scripts/install/openssl/openssl-install.sh
237-
echo "OPENSSL=1" >> /home/EngineScript/install-log.txt
237+
echo "OPENSSL=1" >> /var/log/EngineScript/install-log.txt
238238
fi
239239

240240
# Jemalloc
@@ -244,7 +244,7 @@ fi
244244
# echo "JEMALLOC script has already run."
245245
# else
246246
# /usr/local/bin/enginescript/scripts/install/jemalloc/jemalloc-install.sh
247-
# echo "JEMALLOC=1" >> /home/EngineScript/install-log.txt
247+
# echo "JEMALLOC=1" >> /var/log/EngineScript/install-log.txt
248248
#fi
249249

250250
# Swap
@@ -253,7 +253,7 @@ if [ "${SWAP}" = 1 ];
253253
echo "SWAP script has already run."
254254
else
255255
/usr/local/bin/enginescript/scripts/install/swap/swap-install.sh
256-
echo "SWAP=1" >> /home/EngineScript/install-log.txt
256+
echo "SWAP=1" >> /var/log/EngineScript/install-log.txt
257257
fi
258258

259259
# Kernel Tweaks
@@ -262,7 +262,7 @@ if [ "${KERNEL_TWEAKS}" = 1 ];
262262
echo "KERNEL TWEAKS script has already run."
263263
else
264264
/usr/local/bin/enginescript/scripts/install/kernel/kernel-tweaks-install.sh
265-
echo "KERNEL_TWEAKS=1" >> /home/EngineScript/install-log.txt
265+
echo "KERNEL_TWEAKS=1" >> /var/log/EngineScript/install-log.txt
266266
fi
267267

268268
# Kernel Samepage Merging
@@ -271,7 +271,7 @@ if [ "${KSM}" = 1 ];
271271
echo "KSM script has already run."
272272
else
273273
/usr/local/bin/enginescript/scripts/install/kernel/ksm.sh
274-
echo "KSM=1" >> /home/EngineScript/install-log.txt
274+
echo "KSM=1" >> /var/log/EngineScript/install-log.txt
275275
fi
276276

277277
# Raising System File Limits
@@ -280,7 +280,7 @@ if [ "${SFL}" = 1 ];
280280
echo "SYSTEM FILE LIMITS script has already run."
281281
else
282282
/usr/local/bin/enginescript/scripts/install/system-misc/file-limits.sh
283-
echo "SFL=1" >> /home/EngineScript/install-log.txt
283+
echo "SFL=1" >> /var/log/EngineScript/install-log.txt
284284
fi
285285

286286
# NTP
@@ -289,7 +289,7 @@ if [ "${NTP}" = 1 ];
289289
echo "NTP script has already run."
290290
else
291291
/usr/local/bin/enginescript/scripts/install/systemd/timesyncd.sh
292-
echo "NTP=1" >> /home/EngineScript/install-log.txt
292+
echo "NTP=1" >> /var/log/EngineScript/install-log.txt
293293
fi
294294

295295
# THP
@@ -299,7 +299,7 @@ fi
299299
#echo "THP script has already run."
300300
#else
301301
#/usr/local/bin/enginescript/scripts/install/systemd/thp.sh
302-
#echo "THP=1" >> /home/EngineScript/install-log.txt
302+
#echo "THP=1" >> /var/log/EngineScript/install-log.txt
303303
#fi
304304

305305
# PCRE
@@ -308,7 +308,7 @@ if [ "${PCRE}" = 1 ];
308308
echo "PCRE script has already run."
309309
else
310310
/usr/local/bin/enginescript/scripts/install/pcre/pcre-install.sh
311-
echo "PCRE=1" >> /home/EngineScript/install-log.txt
311+
echo "PCRE=1" >> /var/log/EngineScript/install-log.txt
312312
fi
313313

314314
# zlib
@@ -317,7 +317,7 @@ if [ "${ZLIB}" = 1 ];
317317
echo "ZLIB script has already run."
318318
else
319319
/usr/local/bin/enginescript/scripts/install/zlib/zlib-install.sh
320-
echo "ZLIB=1" >> /home/EngineScript/install-log.txt
320+
echo "ZLIB=1" >> /var/log/EngineScript/install-log.txt
321321
fi
322322

323323
# liburing
@@ -326,7 +326,7 @@ if [ "${LIBURING}" = 1 ];
326326
echo "LIBURING script has already run."
327327
else
328328
/usr/local/bin/enginescript/scripts/install/liburing/liburing-install.sh
329-
echo "LIBURING=1" >> /home/EngineScript/install-log.txt
329+
echo "LIBURING=1" >> /var/log/EngineScript/install-log.txt
330330
fi
331331

332332
# UFW
@@ -335,7 +335,7 @@ if [ "${UFW}" = 1 ];
335335
echo "UFW script has already run."
336336
else
337337
/usr/local/bin/enginescript/scripts/install/ufw/ufw-install.sh
338-
echo "UFW=1" >> /home/EngineScript/install-log.txt
338+
echo "UFW=1" >> /var/log/EngineScript/install-log.txt
339339
fi
340340

341341
# Cron
@@ -344,7 +344,7 @@ if [ "${CRON}" = 1 ];
344344
echo "CRON script has already run."
345345
else
346346
/usr/local/bin/enginescript/scripts/install/cron/cron-install.sh
347-
echo "CRON=1" >> /home/EngineScript/install-log.txt
347+
echo "CRON=1" >> /var/log/EngineScript/install-log.txt
348348
fi
349349

350350
# MariaDB
@@ -385,7 +385,7 @@ if [ "${TOOLS}" = 1 ];
385385
echo "TOOLS script has already run."
386386
else
387387
/usr/local/bin/enginescript/scripts/install/tools/tools-install.sh
388-
echo "TOOLS=1" >> /home/EngineScript/install-log.txt
388+
echo "TOOLS=1" >> /var/log/EngineScript/install-log.txt
389389
fi
390390

391391
# Cleanup

scripts/install/mariadb/mariadb-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fi
102102
STATUS="$(systemctl is-active mysql)"
103103
if [ "${STATUS}" = "active" ]; then
104104
echo "PASSED: MySQL is running."
105-
echo "MARIADB=1" >> /home/EngineScript/install-log.txt
105+
echo "MARIADB=1" >> /var/log/EngineScript/install-log.txt
106106
else
107107
echo "FAILED: MySQL not running. Please diagnose this issue before proceeding."
108108
exit 1

scripts/install/nginx/nginx-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fi
8585
STATUS="$(systemctl is-active nginx)"
8686
if [ "${STATUS}" = "active" ]; then
8787
echo "PASSED: Nginx is running."
88-
echo "NGINX=1" >> /home/EngineScript/install-log.txt
88+
echo "NGINX=1" >> /var/log/EngineScript/install-log.txt
8989
else
9090
echo "FAILED: Nginx not running. Please diagnose this issue before proceeding."
9191
exit 1

scripts/install/php/php-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ service php${PHP_VER}-fpm restart
8888
STATUS="$(systemctl is-active php${PHP_VER}-fpm)"
8989
if [ "${STATUS}" = "active" ]; then
9090
echo "PASSED: PHP ${PHP_VER} is running."
91-
echo "PHP=1" >> /home/EngineScript/install-log.txt
91+
echo "PHP=1" >> /var/log/EngineScript/install-log.txt
9292
else
9393
echo "FAILED: PHP ${PHP_VER} not running. Please diagnose this issue before proceeding."
9494
exit 1

scripts/install/redis/redis-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ sudo systemctl enable redis-server
7777
STATUS="$(systemctl is-active redis)"
7878
if [ "${STATUS}" = "active" ]; then
7979
echo "PASSED: Redis is running."
80-
echo "REDIS=1" >> /home/EngineScript/install-log.txt
80+
echo "REDIS=1" >> /var/log/EngineScript/install-log.txt
8181
else
8282
echo "FAILED: Redis not running. Please diagnose this issue before proceeding."
8383
exit 1

scripts/install/vhost/vhost-install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ else
182182
echo "${BOLD}Preinstallation Check: Passed${NORMAL}"
183183
fi
184184

185+
# Logging
186+
LOG_FILE="/var/log/EngineScript/vhost-install.log"
187+
exec > >(tee -a "${LOG_FILE}") 2>&1
188+
echo "Starting domain installation for ${DOMAIN} at $(date)"
189+
185190
# Continue the installation
186191

187192
# Store SQL credentials

scripts/install/vhost/vhost-remove.sh

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,59 @@ while true; do
4141
done
4242

4343
# Domain Input
44-
echo "For domain name, enter only the domain without https:// or trailing /"
45-
echo "note: lowercase text only"
44+
echo "For the domain name, enter only the domain portion (e.g., 'wordpresstesting')."
45+
echo "Note: lowercase text only, no spaces or special characters. Do not include https:// or www."
4646
echo ""
47-
echo "Examples: wordpresstesting.com"
48-
echo " wordpresstesting.net"
47+
echo "Then, select a valid TLD from the provided list."
4948
echo ""
50-
read -p "Enter Domain name: " DOMAIN
49+
50+
# Prompt for domain name
51+
while true; do
52+
read -p "Enter the domain name (e.g., 'wordpresstesting'): " DOMAIN_NAME
53+
if [[ "$DOMAIN_NAME" =~ ^[a-z0-9-]+$ ]]; then
54+
echo "You entered: ${DOMAIN_NAME}"
55+
break
56+
else
57+
echo "Invalid domain name. Only lowercase letters, numbers, and hyphens are allowed."
58+
fi
59+
done
60+
61+
# Prompt for TLD
5162
echo ""
52-
echo "You entered: ${DOMAIN}"
63+
echo "Select a valid TLD from the list below:"
64+
VALID_TLDS=(
65+
# Common gTLDs
66+
"com" "net" "org" "info" "biz" "name" "pro" "int"
67+
68+
# Popular gTLDs
69+
"io" "dev" "app" "tech" "ai" "cloud" "store" "online" "site" "xyz" "club"
70+
"design" "media" "agency" "solutions" "services" "digital" "studio" "live"
71+
"blog" "news" "shop" "art" "finance" "health" "law" "marketing" "software"
72+
73+
# Country-code TLDs (ccTLDs)
74+
"us" "uk" "ca" "au" "de" "fr" "es" "it" "nl" "se" "no" "fi" "dk" "jp" "cn"
75+
"in" "br" "ru" "za" "mx" "ar" "ch" "at" "be" "pl" "gr" "pt" "tr" "kr" "hk"
76+
"sg" "id" "my" "th" "ph" "vn" "nz" "ie" "il" "sa" "ae" "eg" "ng" "ke" "gh"
77+
"co.uk"
78+
)
79+
select TLD in "${VALID_TLDS[@]}"; do
80+
if [[ -n "$TLD" ]]; then
81+
echo "You selected: ${TLD}"
82+
break
83+
else
84+
echo "Invalid selection. Please choose a valid TLD from the list."
85+
fi
86+
done
87+
88+
# Combine domain name and TLD
89+
DOMAIN="${DOMAIN_NAME}.${TLD}"
90+
echo ""
91+
echo "Full domain: ${DOMAIN}"
92+
93+
# Logging
94+
LOG_FILE="/var/log/EngineScript/vhost-remove.log"
95+
exec > >(tee -a "${LOG_FILE}") 2>&1
96+
echo "Starting domain removal for ${DOMAIN} at $(date)"
5397

5498
# Remove domain from site list
5599
if grep -Fxq "${DOMAIN}" /home/EngineScript/sites-list/sites.sh
@@ -72,14 +116,15 @@ else
72116
echo -e "${BOLD}MySQL Credentials Check: Failed\n\n${NORMAL}${DOMAIN} did not have MySQL credentials.\n\n"
73117
fi
74118

75-
# Remove Nginx vhost
76-
if test -f /etc/nginx/sites-enabled/${DOMAIN}.conf
77-
then
78-
echo -e "${BOLD}Nginx Vhost Removal Check: Passed\n\n${NORMAL}Removing ${DOMAIN} from Nginx...\n\n"
79-
rm -rf /etc/nginx/sites-enabled/${DOMAIN}.conf
80-
else
81-
echo -e "${BOLD}Nginx Vhost Removal Check: Failed\n\n${NORMAL}${DOMAIN} did not have an Nginx vhost.\n\n"
82-
fi
119+
# Remove Nginx vhosts
120+
for VHOST in "/etc/nginx/sites-enabled/${DOMAIN}.conf" "/etc/nginx/admin/admin.${DOMAIN}.conf"; do
121+
if test -f "${VHOST}"; then
122+
echo -e "${BOLD}Nginx Vhost Removal Check: Passed\n\n${NORMAL}Removing ${VHOST}...\n\n"
123+
rm -rf "${VHOST}" || echo "Error: Failed to remove ${VHOST}."
124+
else
125+
echo -e "${BOLD}Nginx Vhost Removal Check: Failed\n\n${NORMAL}${VHOST} did not exist.\n\n"
126+
fi
127+
done
83128

84129
# Remove SSL certificates
85130
if [ -d "/etc/nginx/ssl/${DOMAIN}" ];
@@ -122,14 +167,10 @@ echo "Restarting Nginx and PHP"
122167
/usr/local/bin/enginescript/scripts/functions/alias/alias-restart.sh
123168
echo ""
124169

125-
echo ""
126-
echo "============================================================="
127-
echo ""
128-
echo " Domain removal completed."
129-
echo ""
130-
echo " Returning to main menu in 5 seconds."
131-
echo ""
132-
echo "============================================================="
133-
echo ""
170+
# Summary
171+
echo "----------------------------------------------------------"
172+
echo "Domain removal completed for ${DOMAIN}."
173+
echo "Please verify that all associated files, directories, and configurations have been removed."
174+
echo "----------------------------------------------------------"
134175

135176
sleep 5

setup.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,22 @@ mkdir -p /home/EngineScript/config-backups/php
9999
mkdir -p /home/EngineScript/mysql-credentials
100100
mkdir -p /home/EngineScript/site-backups
101101
mkdir -p /home/EngineScript/sites-list
102-
touch /home/EngineScript/install-log.txt
102+
mkdir -p /var/log/EngineScript
103+
touch /var/log/EngineScript/install-log.txt
104+
touch /var/log/EngineScript/vhost-install.log
105+
touch /var/log/EngineScript/vhost-remove.log
103106

104107
# Return to /usr/src
105108
cd /usr/src
106109

107110
# Create EngineScript Aliases
108-
source /home/EngineScript/install-log.txt
111+
source /var/log/EngineScript/install-log.txt
109112
if [ "${ALIAS}" = 1 ];
110113
then
111114
echo "ALIAS script has already run"
112115
else
113116
/usr/local/bin/enginescript/scripts/install/alias/enginescript-alias-install.sh
114-
echo "ALIAS=1" >> /home/EngineScript/install-log.txt
117+
echo "ALIAS=1" >> /var/log/EngineScript/install-log.txt
115118
fi
116119

117120
# Cleanup

0 commit comments

Comments
 (0)