Update UPDATE.sh

This commit is contained in:
Radovan Ječmenica
2025-05-19 14:07:49 +02:00
committed by GitHub
parent ebed5713eb
commit 8f1b6e365b

View File

@@ -1,7 +1,7 @@
#!/bin/bash
CONFIG_FILE="/etc/openpanel/openpanel/conf/openpanel.config"
MODULE_NAME="mysql"
MODULES_TO_CHECK=("mysql" "filemanager")
# Check if the config file exists
if [[ ! -f "$CONFIG_FILE" ]]; then
@@ -9,27 +9,35 @@ if [[ ! -f "$CONFIG_FILE" ]]; then
exit 1
fi
# Extract current enabled_modules value
# Get the current enabled_modules line
current_modules=$(grep "^enabled_modules=" "$CONFIG_FILE" | cut -d= -f2)
# Check if 'mysql' is already in the list
if echo "$current_modules" | grep -qw "$MODULE_NAME"; then
echo "'$MODULE_NAME' is already enabled."
else
# Add 'mysql' to the comma-separated list
new_modules="${current_modules},$MODULE_NAME"
# Keep track of changes
modules_modified=false
# Update the file in place
sed -i "s/^enabled_modules=.*/enabled_modules=${new_modules}/" "$CONFIG_FILE"
echo "'$MODULE_NAME' added to enabled_modules."
# Loop through each required module
for module in "${MODULES_TO_CHECK[@]}"; do
if echo "$current_modules" | grep -qw "$module"; then
echo "'$module' is already enabled."
else
echo "Adding '$module' to enabled_modules..."
current_modules="${current_modules},$module"
modules_modified=true
fi
done
# Update the file only if we added new modules
if [ "$modules_modified" = true ]; then
sed -i "s/^enabled_modules=.*/enabled_modules=${current_modules}/" "$CONFIG_FILE"
echo "Updated enabled_modules in config file."
fi
# Function to check if a Docker container exists and is running
# Function to check if a Docker container is running
is_container_running() {
docker ps --format '{{.Names}}' | grep -q "^$1$"
}
# Check and flush Redis if openpanel_redis is running
# Flush Redis if openpanel_redis is running
if is_container_running "openpanel_redis"; then
echo "Flushing Redis cache in 'openpanel_redis'..."
docker exec -it openpanel_redis bash -c "redis-cli FLUSHALL"
@@ -37,7 +45,7 @@ else
echo "Container 'openpanel_redis' is not running. Skipping Redis flush."
fi
# Restart OpenPanel if container is running
# Restart OpenPanel if running
if is_container_running "openpanel"; then
echo "Restarting 'openpanel' container..."
docker restart openpanel