From 66a35c1e5de9e032119c16e10fcd1030fd5b0a1f Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Thu, 8 Feb 2024 16:32:31 +0100 Subject: [PATCH] Some debug cosmetic --- src/include/ABHelper.php | 93 ++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/include/ABHelper.php b/src/include/ABHelper.php index 62a4776..b79a404 100644 --- a/src/include/ABHelper.php +++ b/src/include/ABHelper.php @@ -431,7 +431,7 @@ public static function backupContainer($container, $destination) { self::backupLog("Backup created without issues"); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return true; } @@ -570,11 +570,11 @@ public static function errorHandler(int $errno, string $errstr, string $errfile, public static function updateContainer($name) { global $abSettings; - ABHelper::backupLog("Installing planned update for $name..."); + self::backupLog("Installing planned update for $name..."); exec('/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/update_container ' . escapeshellarg($name)); if ($abSettings->updateLogWanted == 'yes') { - ABHelper::notify("Appdata Backup", "Container '$name' updated!", "Container '$name' was successfully updated during this backup run!"); + self::notify("Appdata Backup", "Container '$name' updated!", "Container '$name' was successfully updated during this backup run!"); } } @@ -586,76 +586,76 @@ public static function doBackupMethod($method, $containerListOverride = null,) { switch ($method) { case 'stopAll': - ABHelper::backupLog("Method: Stop all container before continuing."); + self::backupLog("Method: Stop all container before continuing."); foreach ($containerListOverride ? array_reverse($containerListOverride) : $sortedStopContainers as $_container) { foreach ((self::resolveContainer($_container, true) ?: [$_container]) as $container) { - ABHelper::setCurrentContainerName($container); - ABHelper::stopContainer($container); + self::setCurrentContainerName($container); + self::stopContainer($container); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } } - ABHelper::setCurrentContainerName($_container, true); + self::setCurrentContainerName($_container, true); } - ABHelper::setCurrentContainerName(null); + self::setCurrentContainerName(null); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } - ABHelper::backupLog("Starting backup for containers"); + self::backupLog("Starting backup for containers"); foreach ($containerListOverride ? array_reverse($containerListOverride) : $sortedStopContainers as $_container) { foreach (self::resolveContainer($_container, true) ?: [$_container] as $container) { - ABHelper::setCurrentContainerName($container); - if (!ABHelper::backupContainer($container, $abDestination)) { - ABHelper::$errorOccured = true; + self::setCurrentContainerName($container); + if (!self::backupContainer($container, $abDestination)) { + self::$errorOccured = true; } - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } if (in_array($container['Name'], $dockerUpdateList)) { - ABHelper::updateContainer($container['Name']); + self::updateContainer($container['Name']); } } - ABHelper::setCurrentContainerName($_container, true); + self::setCurrentContainerName($_container, true); } - ABHelper::setCurrentContainerName(null); + self::setCurrentContainerName(null); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } - ABHelper::handlePrePostScript($abSettings->postBackupScript, 'post-backup', $abDestination); + self::handlePrePostScript($abSettings->postBackupScript, 'post-backup', $abDestination); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } - ABHelper::backupLog("Set containers to previous state"); + self::backupLog("Set containers to previous state"); foreach ($containerListOverride ?: $sortedStartContainers as $_container) { foreach (self::resolveContainer($_container) ?: [$_container] as $container) { - ABHelper::setCurrentContainerName($container); - ABHelper::startContainer($container); + self::setCurrentContainerName($container); + self::startContainer($container); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } } - ABHelper::setCurrentContainerName($_container, true); + self::setCurrentContainerName($_container, true); } - ABHelper::setCurrentContainerName(null); + self::setCurrentContainerName(null); break; case 'oneAfterTheOther': - ABHelper::backupLog("Method: Stop/Backup/Start"); + self::backupLog("Method: Stop/Backup/Start"); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } @@ -663,41 +663,41 @@ public static function doBackupMethod($method, $containerListOverride = null,) { if ($container['isGroup']) { self::doBackupMethod('stopAll', self::resolveContainer($container)); - ABHelper::setCurrentContainerName($container, true); + self::setCurrentContainerName($container, true); continue; } - ABHelper::setCurrentContainerName($container); - ABHelper::stopContainer($container); + self::setCurrentContainerName($container); + self::stopContainer($container); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } - if (!ABHelper::backupContainer($container, $abDestination)) { - ABHelper::$errorOccured = true; + if (!self::backupContainer($container, $abDestination)) { + self::$errorOccured = true; } - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } if (in_array($container['Name'], $dockerUpdateList)) { - ABHelper::updateContainer($container['Name']); + self::updateContainer($container['Name']); } - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } - ABHelper::startContainer($container); + self::startContainer($container); - if (ABHelper::abortRequested()) { + if (self::abortRequested()) { return false; } - ABHelper::setCurrentContainerName($container, true); + self::setCurrentContainerName($container, true); } - ABHelper::handlePrePostScript($abSettings->postBackupScript, 'post-backup', $abDestination); + self::handlePrePostScript($abSettings->postBackupScript, 'post-backup', $abDestination); break; } @@ -713,12 +713,11 @@ public static function doBackupMethod($method, $containerListOverride = null,) { public static function resolveContainer($container, $reverse = false) { global $dockerContainers, $abSettings; if ($container['isGroup']) { - ABHelper::setCurrentContainerName($container); + self::setCurrentContainerName($container); $groupMembers = $abSettings->getContainerGroups($container['Name']); - ABHelper::backupLog("Reached a group: " . $container['Name'], self::LOGLEVEL_DEBUG); - $sortedGroupContainers = ABHelper::sortContainers($dockerContainers, $abSettings->containerGroupOrder[$container['Name']], $reverse, false, $groupMembers); - ABHelper::backupLog("Containers in this group:", self::LOGLEVEL_DEBUG); - ABHelper::backupLog(print_r($sortedGroupContainers, true), self::LOGLEVEL_DEBUG); + self::backupLog("Reached a group: " . $container['Name'], self::LOGLEVEL_DEBUG); + $sortedGroupContainers = self::sortContainers($dockerContainers, $abSettings->containerGroupOrder[$container['Name']], $reverse, false, $groupMembers); + self::backupLog("Containers in this group: " . implode(', ', array_column($sortedGroupContainers, 'Name')), self::LOGLEVEL_DEBUG); return $sortedGroupContainers; } return false;