From c9109d61bf5ff171c42da82dff0884f610b2affb Mon Sep 17 00:00:00 2001 From: dlandon Date: Fri, 5 Jul 2024 03:47:09 -0500 Subject: [PATCH] Set default value for DOCKER_PID_LIMIT. --- .../dynamix.docker.manager/default.cfg | 1 + .../scripts/dockerconfig | 50 +++++++++++++------ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/emhttp/plugins/dynamix.docker.manager/default.cfg b/emhttp/plugins/dynamix.docker.manager/default.cfg index 4073aa87f..fcaca76a8 100644 --- a/emhttp/plugins/dynamix.docker.manager/default.cfg +++ b/emhttp/plugins/dynamix.docker.manager/default.cfg @@ -8,3 +8,4 @@ DOCKER_USER_NETWORKS="remove" DOCKER_ALLOW_ACCESS="" DOCKER_TIMEOUT=10 DOCKER_READMORE="yes" +DOCKER_PID_LIMIT="" diff --git a/emhttp/plugins/dynamix.docker.manager/scripts/dockerconfig b/emhttp/plugins/dynamix.docker.manager/scripts/dockerconfig index 1bc766fc2..9f8a35ebf 100755 --- a/emhttp/plugins/dynamix.docker.manager/scripts/dockerconfig +++ b/emhttp/plugins/dynamix.docker.manager/scripts/dockerconfig @@ -1,6 +1,6 @@ #!/usr/bin/php -q "no", - "DOCKER_NETWORK_TYPE" => "1", - "DOCKER_IMAGE_FILE" => "/mnt/user/system/docker/docker.img", - "DOCKER_IMAGE_SIZE" => "20", - "DOCKER_APP_CONFIG_PATH" => "/mnt/user/appdata/", - "DOCKER_APP_UNRAID_PATH" => "", - "DOCKER_READMORE" => "yes" + "DOCKER_ENABLED" => "no", + "DOCKER_IMAGE_FILE" => "/mnt/user/system/docker/docker.img", + "DOCKER_IMAGE_SIZE" => "20", + "DOCKER_APP_CONFIG_PATH" => "/mnt/user/appdata/", + "DOCKER_APP_UNRAID_PATH" => "", + "DOCKER_READMORE" => "yes", + "DOCKER_PID_LIMIT" => "" ]; +/* Initialize the new configuration with the default values */ $cfg_new = $cfg_defaults; + +/* Check if the configuration file exists */ if (file_exists($cfgfile)) { - $cfg_old = parse_ini_file($cfgfile); - if (!empty($cfg_old)) { - $cfg_new = array_merge($cfg_defaults, $cfg_old); - if (empty(array_diff($cfg_new, $cfg_old))) unset($cfg_new); - } + /* Parse the existing configuration file */ + $cfg_old = parse_ini_file($cfgfile); + + /* If the existing configuration is not empty, merge it with the defaults */ + if (!empty($cfg_old)) { + /* Merge only missing keys from defaults */ + $cfg_new = array_merge($cfg_defaults, $cfg_old); + + /* If there are no changes between the new and old configurations, unset the new configuration */ + if (empty(array_diff_assoc($cfg_new, $cfg_old))) { + $cfg_new = null; + } + } } + +/* If the new configuration is set, write it to the configuration file */ if (isset($cfg_new)) { - $tmp = ''; - foreach ($cfg_new as $key => $value) $tmp .= "$key=\"$value\"\n"; - file_put_contents($cfgfile, $tmp); + $tmp = ''; + foreach ($cfg_new as $key => $value) { + $tmp .= "$key=\"$value\"\n"; + } + file_put_contents($cfgfile, $tmp); } ?>