allow to run daily backups without automatic updates

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-07-10 21:47:25 +02:00
parent 8021c8119f
commit 79e53f0d00
17 changed files with 203 additions and 89 deletions

View file

@ -44,8 +44,13 @@ class ConfigurationController
}
if (isset($request->getParsedBody()['daily_backup_time'])) {
if (isset($request->getParsedBody()['automatic_updates'])) {
$enableAutomaticUpdates = true;
} else {
$enableAutomaticUpdates = false;
}
$dailyBackupTime = $request->getParsedBody()['daily_backup_time'] ?? '';
$this->configurationManager->SetDailyBackupTime($dailyBackupTime);
$this->configurationManager->SetDailyBackupTime($dailyBackupTime, $enableAutomaticUpdates);
}
if (isset($request->getParsedBody()['delete_daily_backup_time'])) {

View file

@ -26,22 +26,21 @@ class DockerController
$this->configurationManager = $configurationManager;
}
private function PerformRecursiveContainerStart(string $id) : void {
private function PerformRecursiveContainerStart(string $id, bool $pullContainer = true) : void {
$container = $this->containerDefinitionFetcher->GetContainerById($id);
foreach($container->GetDependsOn() as $dependency) {
$this->PerformRecursiveContainerStart($dependency);
}
$pullcontainer = true;
if ($id === 'nextcloud-aio-database') {
if ($this->dockerActionManager->GetDatabasecontainerExitCode() > 0) {
$pullcontainer = false;
$pullContainer = false;
}
}
$this->dockerActionManager->DeleteContainer($container);
$this->dockerActionManager->CreateVolumes($container);
if ($pullcontainer) {
if ($pullContainer) {
$this->dockerActionManager->PullContainer($container);
} else {
error_log('Not pulling the latest database image because the container was not correctly shut down.');
@ -145,12 +144,12 @@ class DockerController
$this->configurationManager->WriteConfig($config);
// Start container
$this->startTopContainer();
$this->startTopContainer(true);
return $response->withStatus(201)->withHeader('Location', '/');
}
public function startTopContainer() : void {
public function startTopContainer(bool $pullContainer) : void {
$config = $this->configurationManager->GetConfig();
// set AIO_TOKEN
$config['AIO_TOKEN'] = bin2hex(random_bytes(24));
@ -161,7 +160,7 @@ class DockerController
$id = self::TOP_CONTAINER;
$this->PerformRecursiveContainerStart($id);
$this->PerformRecursiveContainerStart($id, $pullContainer);
}
public function StartWatchtowerContainer(Request $request, Response $response, $args) : Response {
@ -195,6 +194,11 @@ class DockerController
return $response->withStatus(201)->withHeader('Location', '/');
}
public function stopTopContainer() : void {
$id = self::TOP_CONTAINER;
$this->PerformRecursiveContainerStop($id);
}
public function StartDomaincheckContainer() : void
{
# Don't start if domain is already set