Fix the credentials page for port 8080 and improve the readme

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2021-12-01 01:05:05 +01:00
parent 3f672595ea
commit 1ff0576ee5
4 changed files with 41 additions and 3 deletions

View file

@ -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'

View file

@ -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';
}

View file

@ -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;
}
}

View file

@ -36,9 +36,20 @@ nextcloud/all-in-one:latest
E.g. https://internal.ip.of.this.server:8080<br>
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:<br>
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?**<br>
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?**<br>
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.