mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
Update UPDATE.sh
This commit is contained in:
parent
7d6717091c
commit
2b26715cb0
@ -13,7 +13,6 @@ echo "📥 Installing features for openadmin.."
|
|||||||
wget -O /etc/openpanel/openadmin/config/features.json https://raw.githubusercontent.com/stefanpejcic/openpanel-configuration/refs/heads/main/openadmin/config/features.json
|
wget -O /etc/openpanel/openadmin/config/features.json https://raw.githubusercontent.com/stefanpejcic/openpanel-configuration/refs/heads/main/openadmin/config/features.json
|
||||||
|
|
||||||
systemctl restart admin > /dev/null 2>&1
|
systemctl restart admin > /dev/null 2>&1
|
||||||
|
|
||||||
CONFIG_FILE="/etc/openpanel/openpanel/conf/openpanel.config"
|
CONFIG_FILE="/etc/openpanel/openpanel/conf/openpanel.config"
|
||||||
MODULES_TO_CHECK=("mysql" "domains" "autoinstaller" "filemanager" "php")
|
MODULES_TO_CHECK=("mysql" "domains" "autoinstaller" "filemanager" "php")
|
||||||
|
|
||||||
@ -23,15 +22,23 @@ if [[ ! -f "$CONFIG_FILE" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the current enabled_modules line
|
# Extract the current enabled_modules (strip quotes)
|
||||||
current_modules=$(grep "^enabled_modules=" "$CONFIG_FILE" | cut -d= -f2)
|
current_modules=$(grep "^enabled_modules=" "$CONFIG_FILE" | cut -d= -f2 | sed 's/^"\(.*\)"$/\1/')
|
||||||
|
|
||||||
|
# Convert to array
|
||||||
|
IFS=',' read -ra current_array <<< "$current_modules"
|
||||||
|
|
||||||
|
# Create a set for quick lookup
|
||||||
|
declare -A current_set
|
||||||
|
for mod in "${current_array[@]}"; do
|
||||||
|
current_set["$mod"]=1
|
||||||
|
done
|
||||||
|
|
||||||
# Keep track of changes
|
|
||||||
modules_modified=false
|
modules_modified=false
|
||||||
|
|
||||||
# Loop through each required module
|
# Loop through each required module
|
||||||
for module in "${MODULES_TO_CHECK[@]}"; do
|
for module in "${MODULES_TO_CHECK[@]}"; do
|
||||||
if echo "$current_modules" | grep -qw "$module"; then
|
if [[ -n "${current_set[$module]}" ]]; then
|
||||||
echo "'$module' is already enabled."
|
echo "'$module' is already enabled."
|
||||||
else
|
else
|
||||||
echo "Adding '$module' to enabled_modules..."
|
echo "Adding '$module' to enabled_modules..."
|
||||||
@ -40,12 +47,13 @@ for module in "${MODULES_TO_CHECK[@]}"; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Update the file only if we added new modules
|
# Update the config file only if changed
|
||||||
if [ "$modules_modified" = true ]; then
|
if [ "$modules_modified" = true ]; then
|
||||||
sed -i "s/^enabled_modules=.*/enabled_modules=\"${current_modules}\"/" "$CONFIG_FILE"
|
sed -i "s|^enabled_modules=.*|enabled_modules=\"${current_modules}\"|" "$CONFIG_FILE"
|
||||||
echo "Updated enabled_modules in config file."
|
echo "Updated enabled_modules in config file."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Function to check if a Docker container is running
|
# Function to check if a Docker container is running
|
||||||
is_container_running() {
|
is_container_running() {
|
||||||
docker ps --format '{{.Names}}' | grep -q "^$1$"
|
docker ps --format '{{.Names}}' | grep -q "^$1$"
|
||||||
|
Loading…
Reference in New Issue
Block a user