From 1ff0576ee5796a0730dbf1752cf399e4308ffb9e Mon Sep 17 00:00:00 2001 From: szaimen Date: Wed, 1 Dec 2021 01:05:05 +0100 Subject: [PATCH] Fix the credentials page for port 8080 and improve the readme Signed-off-by: szaimen --- php/public/index.php | 2 +- php/src/Data/DataConst.php | 4 ++++ php/src/Data/Setup.php | 27 +++++++++++++++++++++++++-- readme.md | 11 +++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/php/public/index.php b/php/public/index.php index 29c467d4..f970b15a 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -98,7 +98,7 @@ $app->get('/setup', function ($request, $response, $args) use ($container) { /** @var \AIO\Data\Setup $setup */ $setup = $container->get(\AIO\Data\Setup::class); - if(!$setup->CanBeInstalled()) { + if(!$setup->CanBeInstalled($request)) { return $view->render( $response, 'already-installed.twig' diff --git a/php/src/Data/DataConst.php b/php/src/Data/DataConst.php index 4c7643d8..033e1928 100644 --- a/php/src/Data/DataConst.php +++ b/php/src/Data/DataConst.php @@ -23,6 +23,10 @@ class DataConst { return self::GetDataDirectory() . '/configuration.json'; } + public static function GetTempSetupFile() : string { + return self::GetDataDirectory() . '/temp.setup'; + } + public static function GetBackupSecretFile() : string { return self::GetDataDirectory() . '/backupsecret'; } diff --git a/php/src/Data/Setup.php b/php/src/Data/Setup.php index 2ab87e36..e26333e3 100644 --- a/php/src/Data/Setup.php +++ b/php/src/Data/Setup.php @@ -3,6 +3,7 @@ namespace AIO\Data; use AIO\Auth\PasswordGenerator; +use Psr\Http\Message\ServerRequestInterface as Request; class Setup { @@ -26,7 +27,29 @@ class Setup return $password; } - public function CanBeInstalled() : bool { - return !file_exists(DataConst::GetConfigFile()); + public function CanBeInstalled(?Request $request) : bool { + if (file_exists(DataConst::GetConfigFile())) { + return false; + } + + if ($request === null) { + return true; + } + + $uri = $request->getUri(); + if ($uri->getPort() === '8080') { + if (!file_exists(DataConst::GetTempSetupFile())) { + if(!is_dir(DataConst::GetDataDirectory())) { + mkdir(DataConst::GetDataDirectory()); + } + file_put_contents(DataConst::GetTempSetupFile(), ''); + return false; + } else { + unlink(DataConst::GetTempSetupFile()); + return true; + } + } + + return true; } } diff --git a/readme.md b/readme.md index 011cc1ce..03587047 100644 --- a/readme.md +++ b/readme.md @@ -36,9 +36,20 @@ nextcloud/all-in-one:latest E.g. https://internal.ip.of.this.server:8080
If your server has port 80 and 8443 open and you point a domain to your server, you can get a valid certificate automatially by opening the Nextcloud AIO Interface via:
https://your-domain-that-points-to-this-server.tld:8443 +4. You should now see your login credentials. If not, please have a look at the FAQ section below. Explanation of used ports: - `80`: redirects to Nextcloud (HTTP) (is used for getting the certificate via ACME http-challenge for mastercontainer) - `8080`: Master Container Interface with self-signed certificate (HTTPS) (works always, also if only access via IP-address is possible, e.g. `https://internal.ip.address:8080/`) - `8443`: Master Container Interface with valid automatic certificate via Let's Encrypt! (HTTPS) (Only works if you access the container via a public domain, e.g. `https://public.domain.com:8443/` and not via IP-address.) + +## FAQ +- **Is running Nextcloud AIO via Docker Compose supported?**
+ Unfortunately no, as you most likely run into many issues when trying to do so. +- **I don't see the initial screen with my login credentials. What to do?**
+ Please try to remove the mastercontainer first by running: + ``` + sudo docker stop nextcloud-aio-mastercontainer; sudo docker rm nextcloud-aio-mastercontainer; sudo docker rm nextcloud_aio_mastercontainer + ``` + Afterwards, install it again by running the above mentioned command again.