diff --git a/Containers/clamav/Dockerfile b/Containers/clamav/Dockerfile index 33b95261..8b73e7af 100644 --- a/Containers/clamav/Dockerfile +++ b/Containers/clamav/Dockerfile @@ -1,5 +1,6 @@ # Probably from this file: https://github.com/Cisco-Talos/clamav/blob/main/Dockerfile FROM clamav/clamav:0.104.2-3 +RUN apk add --update --no-cache tzdata COPY clamav.conf /tmp/ RUN cat /tmp/clamav.conf >> /etc/clamav/clamd.conf diff --git a/Containers/collabora/Dockerfile b/Containers/collabora/Dockerfile index a5578d17..dbb1a235 100644 --- a/Containers/collabora/Dockerfile +++ b/Containers/collabora/Dockerfile @@ -1,2 +1,15 @@ # From a file located probably somewhere here: https://github.com/CollaboraOnline/online/tree/master/docker -FROM collabora/code:21.11.4.2.1 \ No newline at end of file +FROM collabora/code:21.11.4.2.1 + +USER root + +RUN set -ex; \ + \ + apt-get update; \ + export DEBIAN_FRONTEND=noninteractive; \ + apt-get install -y --no-install-recommends \ + tzdata \ + ; \ + rm -rf /var/lib/apt/lists/* + +USER 104 diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index b47de06b..21f1bd9d 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -198,6 +198,7 @@ RUN set -ex; \ gnupg \ git \ postgresql-client \ + tzdata \ ; \ rm -rf /var/lib/apt/lists/* diff --git a/manual-install/update-yaml.sh b/manual-install/update-yaml.sh index ebf04ef9..de3987b7 100644 --- a/manual-install/update-yaml.sh +++ b/manual-install/update-yaml.sh @@ -67,6 +67,7 @@ sed -i 's|AIO_TOKEN=|AIO_TOKEN=123456 # Has no function but needs to be sed -i 's|AIO_URL=|AIO_URL=localhost # Has no function but needs to be set!|' sample.conf sed -i 's|NC_DOMAIN=|NC_DOMAIN=yourdomain.com # TODO! Needs to be changed to the domain that you want to use for Nextcloud.|' sample.conf sed -i 's|NEXTCLOUD_PASSWORD=|NEXTCLOUD_PASSWORD= # TODO! This is the password of the initially created Nextcloud admin with username "admin".|' sample.conf +sed -i 's|TIMEZONE=|TIMEZONE=Europe/Berlin # TODO! This is the timezone that your containers will use.|' sample.conf sed -i 's|=$|= # TODO! This needs to be a unique and good password!|' sample.conf cat sample.conf diff --git a/php/containers.json b/php/containers.json index dc689a6e..968e6c3f 100644 --- a/php/containers.json +++ b/php/containers.json @@ -24,7 +24,8 @@ "COLLABORA_HOST=nextcloud-aio-collabora", "TALK_HOST=nextcloud-aio-talk", "APACHE_PORT=%APACHE_PORT%", - "ONLYOFFICE_HOST=nextcloud-aio-onlyoffice" + "ONLYOFFICE_HOST=nextcloud-aio-onlyoffice", + "TZ=%TIMEZONE%" ], "volumes": [ { @@ -68,7 +69,8 @@ "environmentVariables": [ "POSTGRES_PASSWORD=%DATABASE_PASSWORD%", "POSTGRES_DB=nextcloud_database", - "POSTGRES_USER=nextcloud" + "POSTGRES_USER=nextcloud", + "TZ=%TIMEZONE%" ], "maxShutdownTime": 1800, "restartPolicy": "unless-stopped" @@ -134,7 +136,8 @@ "COLLABORA_HOST=nextcloud-aio-collabora", "TALK_ENABLED=%TALK_ENABLED%", "ONLYOFFICE_HOST=nextcloud-aio-onlyoffice", - "DAILY_BACKUP_RUNNING=%DAILY_BACKUP_RUNNING%" + "DAILY_BACKUP_RUNNING=%DAILY_BACKUP_RUNNING%", + "TZ=%TIMEZONE%" ], "maxShutdownTime": 10, "restartPolicy": "unless-stopped" @@ -149,7 +152,8 @@ "6379" ], "environmentVariables": [ - "REDIS_HOST_PASSWORD=%REDIS_PASSWORD%" + "REDIS_HOST_PASSWORD=%REDIS_PASSWORD%", + "TZ=%TIMEZONE%" ], "volumes": [], "secrets": [ @@ -169,7 +173,8 @@ ], "environmentVariables": [ "aliasgroup1=https://%NC_DOMAIN%:443", - "extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:logging.level=warning" + "extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:logging.level=warning", + "TZ=%TIMEZONE%" ], "volumes": [], "secrets": [], @@ -192,7 +197,8 @@ "NC_DOMAIN=%NC_DOMAIN%", "TURN_SECRET=%TURN_SECRET%", "SIGNALING_SECRET=%SIGNALING_SECRET%", - "JANUS_API_KEY=%JANUS_API_KEY%" + "JANUS_API_KEY=%JANUS_API_KEY%", + "TZ=%TIMEZONE%" ], "volumes": [], "secrets": [ @@ -314,7 +320,9 @@ "internalPorts": [ "3310" ], - "environmentVariables": [], + "environmentVariables": [ + "TZ=%TIMEZONE%" + ], "volumes": [ { "name": "nextcloud_aio_clamav", @@ -335,7 +343,9 @@ "internalPorts": [ "80" ], - "environmentVariables": [], + "environmentVariables": [ + "TZ=%TIMEZONE%" + ], "volumes": [ { "name": "nextcloud_aio_onlyoffice", diff --git a/php/public/index.php b/php/public/index.php index eeea480d..4d409952 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -96,6 +96,7 @@ $app->get('/containers', function ($request, $response, $args) use ($container) 'borg_restore_password' => $configurationManager->GetBorgRestorePassword(), 'daily_backup_time' => $configurationManager->GetDailyBackupTime(), 'is_daily_backup_running' => $configurationManager->isDailyBackupRunning(), + 'timezone' => $configurationManager->GetTimezone(), ]); })->setName('profile'); $app->get('/login', function ($request, $response, $args) use ($container) { diff --git a/php/src/Controller/ConfigurationController.php b/php/src/Controller/ConfigurationController.php index 70dd6c54..f19e33ab 100644 --- a/php/src/Controller/ConfigurationController.php +++ b/php/src/Controller/ConfigurationController.php @@ -52,6 +52,15 @@ class ConfigurationController $this->configurationManager->DeleteDailyBackupTime(); } + if (isset($request->getParsedBody()['delete_timezone'])) { + $this->configurationManager->DeleteTimezone(); + } + + if (isset($request->getParsedBody()['timezone'])) { + $timezone = $request->getParsedBody()['timezone'] ?? ''; + $this->configurationManager->SetTimezone($timezone); + } + if (isset($request->getParsedBody()['options-form'])) { if (isset($request->getParsedBody()['collabora']) && isset($request->getParsedBody()['onlyoffice'])) { throw new InvalidSettingConfigurationException("Collabora and Onlyoffice are not allowed to be enabled at the same time!"); diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 40990805..1cc31341 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -479,4 +479,33 @@ class ConfigurationManager } return false; } + + public function GetTimezone() : string { + $config = $this->GetConfig(); + if(!isset($config['timezone'])) { + $config['timezone'] = ''; + } + + return $config['timezone']; + } + + public function SetTimezone(string $timezone) : void { + if ($timezone === "") { + throw new InvalidSettingConfigurationException("The timezone must not be empty!"); + } + + if (!preg_match("#[a-zA-Z0-9_-/+]+$#", $timezone)) { + throw new InvalidSettingConfigurationException("The entered timezone does not seem to be a valid timezone!"); + } + + $config = $this->GetConfig(); + $config['timezone'] = $timezone; + $this->WriteConfig($config); + } + + public function DeleteTimezone() : void { + $config = $this->GetConfig(); + $config['timezone'] = ''; + $this->WriteConfig($config); + } } diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 1e8c1270..e07d6bb9 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -280,6 +280,8 @@ class DockerActionManager } else { $replacements[1] = ''; } + } elseif ($out[1] === 'TIMEZONE') { + $replacements[1] = $this->configurationManager->GetTimezone(); } else { $replacements[1] = $this->configurationManager->GetSecret($out[1]); } diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 35ed0917..056a9d66 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -398,7 +398,32 @@ - The new password needs to be at least 24 characters long. Allowed characters are the latin characters a-z, A-Z, 0-9 and spaces. + The new password needs to be at least 24 characters long. Allowed characters are the latin characters a-z, A-Z, 0-9 and spaces.

+ +

Timezone change

+ In order to get the correct time values for certain Nextcloud features, it makes sense to set the timezone for Nextcloud to the one that your users mainly use. Please note that this setting does not apply to the mastercontainer and any backup option.

+ {% if isAnyRunning == true %} + You can change the timezone when your containers are stopped.

+ {% else %} + {% if timezone == "" %} + You can configure the timezone for Nextcloud below:

+
+ + + + +
+ You need to make sure that the timezone that you enter is valid. An example is Europe/Berlin. You can get valid values by looking at the 'TZ database name' column of this list: click here.

+ {% else %} + The timezone for Nextcloud is currently set to {{ timezone }}. You can reset the timezone again by clicking on the button below.

+
+ + + + +
+ {% endif %} + {% endif %} {% endif %} {% endif %} {% endif %}