Skip to content

Commit 605a864

Browse files
authored
Control Panel fixes
1 parent 4253b36 commit 605a864

8 files changed

Lines changed: 174 additions & 7 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ Want to support EngineScript? [Sponsor this project](https://github.com/sponsors
138138
|**/usr/local/bin/enginescript** |EngineScript source|
139139
|**/var/lib/mysql** |MySQL database|
140140
|**/var/log** |Server logs|
141-
|**/var/www/admin/enginescript** |Tools that may be accessed via server IP address or admin.YOURDOMAIN subdomain|
141+
|**/var/www/admin/control-panel**|EngineScript Admin Dashboard|
142+
|**/var/www/admin/tools** |Admin tools (phpMyAdmin, TinyFileManager, phpSysInfo, Adminer)|
142143
|**/var/www/sites/*YOURDOMAIN*/html**|Root directory for your WordPress installation|
143144

144145
### EngineScript Commands

config/var/www/admin/control-panel/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ The dashboard is designed to work with RESTful API endpoints for real-time data:
3939

4040
## Installation
4141

42-
The dashboard is automatically deployed by the EngineScript installation process to `/var/www/admin/enginescript/`.
42+
The dashboard is automatically deployed by the EngineScript installation process to `/var/www/admin/control-panel/`.

config/var/www/admin/phpsysinfo/phpsysinfo.ini renamed to config/var/www/admin/tools/phpsysinfo/phpsysinfo.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ SHOW_SERIAL=false
173173
ACCESS="command"
174174

175175
[docker]
176-
ACCESS="command"
176+
ACCESS="command"
File renamed without changes.

scripts/functions/auto-upgrade/normal-auto-upgrade.sh

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,140 @@ verify_installation_completion
2121
# Start Main Script
2222

2323
# Upgrade Scripts will be found below:
24+
25+
#----------------------------------------------------------------------------------
26+
# Migration: Admin Tools Directory Structure (2025-12-31)
27+
#
28+
# Migrates admin tools from old /var/www/admin/enginescript/ structure
29+
# to new separated structure:
30+
# - Control Panel: /var/www/admin/control-panel/
31+
# - Tools: /var/www/admin/tools/
32+
#
33+
# This ensures phpMyAdmin and other tools survive EngineScript updates.
34+
#----------------------------------------------------------------------------------
35+
36+
migrate_admin_tools() {
37+
local OLD_ADMIN_DIR="/var/www/admin/enginescript"
38+
local NEW_TOOLS_DIR="/var/www/admin/tools"
39+
local NEW_PANEL_DIR="/var/www/admin/control-panel"
40+
local MIGRATION_NEEDED=0
41+
42+
# Check if old directory structure exists
43+
if [[ -d "$OLD_ADMIN_DIR" ]]; then
44+
echo "============================================================="
45+
echo "Admin Tools Migration: Detected old directory structure"
46+
echo "============================================================="
47+
48+
# Create new directories
49+
mkdir -p "$NEW_TOOLS_DIR"
50+
mkdir -p "$NEW_PANEL_DIR"
51+
52+
# Migrate phpMyAdmin (preserve config!)
53+
if [[ -d "$OLD_ADMIN_DIR/phpmyadmin" ]]; then
54+
echo "Migrating phpMyAdmin..."
55+
if [[ ! -d "$NEW_TOOLS_DIR/phpmyadmin" ]]; then
56+
mv "$OLD_ADMIN_DIR/phpmyadmin" "$NEW_TOOLS_DIR/phpmyadmin"
57+
echo " ✓ phpMyAdmin migrated to $NEW_TOOLS_DIR/phpmyadmin"
58+
MIGRATION_NEEDED=1
59+
else
60+
echo " ℹ phpMyAdmin already exists in new location, skipping"
61+
fi
62+
fi
63+
64+
# Migrate Adminer
65+
if [[ -d "$OLD_ADMIN_DIR/adminer" ]]; then
66+
echo "Migrating Adminer..."
67+
if [[ ! -d "$NEW_TOOLS_DIR/adminer" ]]; then
68+
mv "$OLD_ADMIN_DIR/adminer" "$NEW_TOOLS_DIR/adminer"
69+
echo " ✓ Adminer migrated to $NEW_TOOLS_DIR/adminer"
70+
MIGRATION_NEEDED=1
71+
else
72+
echo " ℹ Adminer already exists in new location, skipping"
73+
fi
74+
fi
75+
76+
# Migrate TinyFileManager (preserve config!)
77+
if [[ -d "$OLD_ADMIN_DIR/tinyfilemanager" ]]; then
78+
echo "Migrating TinyFileManager..."
79+
if [[ ! -d "$NEW_TOOLS_DIR/tinyfilemanager" ]]; then
80+
mv "$OLD_ADMIN_DIR/tinyfilemanager" "$NEW_TOOLS_DIR/tinyfilemanager"
81+
echo " ✓ TinyFileManager migrated to $NEW_TOOLS_DIR/tinyfilemanager"
82+
MIGRATION_NEEDED=1
83+
else
84+
echo " ℹ TinyFileManager already exists in new location, skipping"
85+
fi
86+
fi
87+
88+
# Migrate phpSysInfo
89+
if [[ -d "$OLD_ADMIN_DIR/phpsysinfo" ]]; then
90+
echo "Migrating phpSysInfo..."
91+
if [[ ! -d "$NEW_TOOLS_DIR/phpsysinfo" ]]; then
92+
mv "$OLD_ADMIN_DIR/phpsysinfo" "$NEW_TOOLS_DIR/phpsysinfo"
93+
echo " ✓ phpSysInfo migrated to $NEW_TOOLS_DIR/phpsysinfo"
94+
MIGRATION_NEEDED=1
95+
else
96+
echo " ℹ phpSysInfo already exists in new location, skipping"
97+
fi
98+
fi
99+
100+
# Migrate phpinfo
101+
if [[ -d "$OLD_ADMIN_DIR/phpinfo" ]]; then
102+
echo "Migrating phpinfo..."
103+
if [[ ! -d "$NEW_TOOLS_DIR/phpinfo" ]]; then
104+
mv "$OLD_ADMIN_DIR/phpinfo" "$NEW_TOOLS_DIR/phpinfo"
105+
echo " ✓ phpinfo migrated to $NEW_TOOLS_DIR/phpinfo"
106+
MIGRATION_NEEDED=1
107+
else
108+
echo " ℹ phpinfo already exists in new location, skipping"
109+
fi
110+
fi
111+
112+
# Migrate OpCache-GUI
113+
if [[ -d "$OLD_ADMIN_DIR/opcache-gui" ]]; then
114+
echo "Migrating OpCache-GUI..."
115+
if [[ ! -d "$NEW_TOOLS_DIR/opcache-gui" ]]; then
116+
mv "$OLD_ADMIN_DIR/opcache-gui" "$NEW_TOOLS_DIR/opcache-gui"
117+
echo " ✓ OpCache-GUI migrated to $NEW_TOOLS_DIR/opcache-gui"
118+
MIGRATION_NEEDED=1
119+
else
120+
echo " ℹ OpCache-GUI already exists in new location, skipping"
121+
fi
122+
fi
123+
124+
# Set permissions on migrated tools
125+
if [[ "$MIGRATION_NEEDED" -eq 1 ]]; then
126+
echo "Setting permissions on migrated tools..."
127+
chown -R www-data:www-data "$NEW_TOOLS_DIR"
128+
find "$NEW_TOOLS_DIR" -type d -exec chmod 755 {} \;
129+
find "$NEW_TOOLS_DIR" -type f -exec chmod 644 {} \;
130+
131+
echo ""
132+
echo "============================================================="
133+
echo "Admin Tools Migration Complete!"
134+
echo "============================================================="
135+
echo ""
136+
echo "Tools are now stored in: $NEW_TOOLS_DIR"
137+
echo "Control panel is now in: $NEW_PANEL_DIR"
138+
echo ""
139+
echo "This separation ensures your tool configurations"
140+
echo "(especially phpMyAdmin) survive future EngineScript updates."
141+
echo "============================================================="
142+
echo ""
143+
fi
144+
145+
# Clean up old directory if empty
146+
if [[ -d "$OLD_ADMIN_DIR" ]]; then
147+
# Check if directory is empty (only contains . and ..)
148+
if [[ -z "$(ls -A "$OLD_ADMIN_DIR" 2>/dev/null)" ]]; then
149+
rmdir "$OLD_ADMIN_DIR" 2>/dev/null || true
150+
echo "Removed empty old admin directory: $OLD_ADMIN_DIR"
151+
else
152+
echo "Note: Old admin directory still contains files: $OLD_ADMIN_DIR"
153+
echo " Please review and remove manually if no longer needed."
154+
fi
155+
fi
156+
fi
157+
}
158+
159+
# Run migration check
160+
migrate_admin_tools

scripts/install/tools/frontend/phpsysinfo-install.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ fi
2929

3030
# Clone the phpSysinfo repository
3131
git clone --depth 1 https://github.com/phpsysinfo/phpsysinfo.git /var/www/admin/tools/phpsysinfo
32-
cp -rf /usr/local/bin/enginescript/config/var/www/admin/phpsysinfo/phpsysinfo.ini /var/www/admin/tools/phpsysinfo/phpsysinfo.ini
32+
33+
# Copy EngineScript phpSysinfo configuration template
34+
# Config templates are stored in /config/var/www/admin/tools/ to mirror the install location
35+
cp -rf /usr/local/bin/enginescript/config/var/www/admin/tools/phpsysinfo/phpsysinfo.ini /var/www/admin/tools/phpsysinfo/phpsysinfo.ini
3336
sed -i "s|SEDPHPVER|${PHP_VER}|g" /var/www/admin/tools/phpsysinfo/phpsysinfo.ini
3437

3538
# Set permissions for the EngineScript frontend

scripts/install/tools/frontend/tiny-file-manager-install.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ if curl -fsSL --connect-timeout 30 --max-time 60 "${TFM_ZIP_URL}" -o "${TFM_ZIP_
4444
cp -r "/tmp/tinyfilemanager-${TINYFILEMANAGER_VER}/"* "$TFM_DIR/"
4545

4646
# Copy our custom configuration file
47-
if [[ -f "/usr/local/bin/enginescript/config/var/www/admin/tinyfilemanager/config.php" ]]; then
48-
cp /usr/local/bin/enginescript/config/var/www/admin/tinyfilemanager/config.php "$TFM_DIR/"
47+
# Config templates are stored in /config/var/www/admin/tools/ to mirror the install location
48+
if [[ -f "/usr/local/bin/enginescript/config/var/www/admin/tools/tinyfilemanager/config.php" ]]; then
49+
cp /usr/local/bin/enginescript/config/var/www/admin/tools/tinyfilemanager/config.php "$TFM_DIR/"
4950
fi
5051

5152
# Set proper permissions

scripts/update/enginescript-update.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,37 @@ echo ""
8282
# --------------------------------------------------------
8383
# Update EngineScript Frontend
8484

85+
# Safety Check: Verify we're only wiping the control-panel directory
86+
# This prevents accidental deletion of admin tools (phpMyAdmin, etc.)
87+
CONTROL_PANEL_DIR="/var/www/admin/control-panel"
88+
TOOLS_DIR="/var/www/admin/tools"
89+
90+
# Verify tools directory exists and is not empty (contains user configurations)
91+
if [[ -d "$TOOLS_DIR" ]]; then
92+
TOOLS_COUNT=$(find "$TOOLS_DIR" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l)
93+
if [[ "$TOOLS_COUNT" -gt 0 ]]; then
94+
echo "✓ Admin tools directory verified: $TOOLS_COUNT tool(s) found in $TOOLS_DIR"
95+
echo " Tools will NOT be affected by this update."
96+
fi
97+
else
98+
echo "ℹ Admin tools directory not found. Creating..."
99+
mkdir -p "$TOOLS_DIR"
100+
fi
101+
85102
# Admin Control Panel - Remove old files and replace with new version
86103
# NOTE: Only the control-panel directory is wiped on updates.
87104
# Admin tools (phpMyAdmin, TinyFileManager, phpSysInfo, Adminer, phpinfo)
88105
# are stored in /var/www/admin/tools/ and are NOT affected by updates.
89106
echo "Cleaning up old Admin Control Panel files..."
90-
rm -rf /var/www/admin/control-panel/*
107+
108+
# Safety: Double-check we're targeting the correct directory
109+
if [[ "$CONTROL_PANEL_DIR" == "/var/www/admin/control-panel" ]]; then
110+
rm -rf "${CONTROL_PANEL_DIR:?}"/*
111+
else
112+
echo "ERROR: Control panel directory path mismatch. Aborting for safety."
113+
exit 1
114+
fi
115+
91116
/usr/local/bin/enginescript/scripts/install/tools/frontend/admin-control-panel-install.sh
92117

93118
# Update configuration files from main credentials file

0 commit comments

Comments
 (0)