add onlyoffice and allow to disable talk and collabora

Signed-off-by: szaimen <szaimen@e.mail.de>
This commit is contained in:
szaimen 2022-03-17 10:13:21 +01:00
parent 68ac85e60b
commit 1b86445b6a
15 changed files with 250 additions and 24 deletions

View file

@ -117,3 +117,12 @@ updates:
labels:
- 3. to review
- dependencies
- package-ecosystem: "docker"
directory: "/Containers/onlyoffice"
schedule:
interval: "daily"
time: "12:00"
open-pull-requests-limit: 10
labels:
- 3. to review
- dependencies

View file

@ -31,6 +31,12 @@
reverse_proxy {$COLLABORA_HOST}:9980
}
# Onlyoffice
route /onlyoffice/* {
uri strip_prefix /onlyoffice
reverse_proxy {$ONLYOFFICE_HOST}:80
}
# Nextcloud
route {
rewrite /.well-known/carddav /remote.php/dav

View file

@ -277,32 +277,60 @@ php /var/www/html/occ config:system:set trusted_proxies 0 --value="127.0.0.1"
php /var/www/html/occ config:app:set notify_push base_endpoint --value="https://$NC_DOMAIN/push"
# Collabora
if ! [ -d "/var/www/html/custom_apps/richdocuments" ]; then
if [ "$COLLABORA_ENABLED" = 'yes' ]; then
if ! [ -d "/var/www/html/custom_apps/richdocuments" ]; then
php /var/www/html/occ app:install richdocuments
elif [ "$(php /var/www/html/occ config:app:get richdocuments enabled)" = "no" ]; then
elif [ "$(php /var/www/html/occ config:app:get richdocuments enabled)" = "no" ]; then
php /var/www/html/occ app:enable richdocuments
else
else
php /var/www/html/occ app:update richdocuments
fi
php /var/www/html/occ config:app:set richdocuments wopi_url --value="https://$NC_DOMAIN/"
# php /var/www/html/occ richdocuments:activate-config
# Fix https://github.com/nextcloud/all-in-one/issues/188:
php /var/www/html/occ config:system:set allow_local_remote_servers --type=bool --value=true
else
if [ -d "/var/www/html/custom_apps/richdocuments" ]; then
php /var/www/html/occ app:remove richdocuments
fi
fi
# OnlyOffice
if [ "$ONLYOFFICE_ENABLED" = 'yes' ]; then
if ! [ -d "/var/www/html/custom_apps/onlyoffice" ]; then
php /var/www/html/occ app:install onlyoffice
elif [ "$(php /var/www/html/occ config:app:get onlyoffice enabled)" = "no" ]; then
php /var/www/html/occ app:enable onlyoffice
else
php /var/www/html/occ app:update onlyoffice
fi
php /var/www/html/occ config:app:set onlyoffice DocumentServerUrl --value="https://$NC_DOMAIN/onlyoffice"
else
if [ -d "/var/www/html/custom_apps/onlyoffice" ]; then
php /var/www/html/occ app:remove onlyoffice
fi
fi
php /var/www/html/occ config:app:set richdocuments wopi_url --value="https://$NC_DOMAIN/"
# php /var/www/html/occ richdocuments:activate-config
# Fix https://github.com/nextcloud/all-in-one/issues/188:
php /var/www/html/occ config:system:set allow_local_remote_servers --type=bool --value=true
# Talk
if ! [ -d "/var/www/html/custom_apps/spreed" ]; then
if [ "$TALK_ENABLED" = 'yes' ]; then
if ! [ -d "/var/www/html/custom_apps/spreed" ]; then
php /var/www/html/occ app:install spreed
elif [ "$(php /var/www/html/occ config:app:get spreed enabled)" = "no" ]; then
elif [ "$(php /var/www/html/occ config:app:get spreed enabled)" = "no" ]; then
php /var/www/html/occ app:enable spreed
else
else
php /var/www/html/occ app:update spreed
fi
STUN_SERVERS="[\"$NC_DOMAIN:3478\"]"
TURN_SERVERS="[{\"server\":\"$NC_DOMAIN:3478\",\"secret\":\"$TURN_SECRET\",\"protocols\":\"udp,tcp\"}]"
SIGNALING_SERVERS="{\"servers\":[{\"server\":\"https://$NC_DOMAIN/standalone-signaling/\",\"verify\":true}],\"secret\":\"$SIGNALING_SECRET\"}"
php /var/www/html/occ config:app:set spreed stun_servers --value="$STUN_SERVERS" --output json
php /var/www/html/occ config:app:set spreed turn_servers --value="$TURN_SERVERS" --output json
php /var/www/html/occ config:app:set spreed signaling_servers --value="$SIGNALING_SERVERS" --output json
else
if [ -d "/var/www/html/custom_apps/spreed" ]; then
php /var/www/html/occ app:remove spreed
fi
fi
STUN_SERVERS="[\"$NC_DOMAIN:3478\"]"
TURN_SERVERS="[{\"server\":\"$NC_DOMAIN:3478\",\"secret\":\"$TURN_SECRET\",\"protocols\":\"udp,tcp\"}]"
SIGNALING_SERVERS="{\"servers\":[{\"server\":\"https://$NC_DOMAIN/standalone-signaling/\",\"verify\":true}],\"secret\":\"$SIGNALING_SECRET\"}"
php /var/www/html/occ config:app:set spreed stun_servers --value="$STUN_SERVERS" --output json
php /var/www/html/occ config:app:set spreed turn_servers --value="$TURN_SERVERS" --output json
php /var/www/html/occ config:app:set spreed signaling_servers --value="$SIGNALING_SERVERS" --output json
# Clamav
if [ "$CLAMAV_ENABLED" = 'yes' ]; then

View file

@ -0,0 +1,2 @@
# From https://github.com/ONLYOFFICE/Docker-DocumentServer/blob/master/Dockerfile
FROM onlyoffice/documentserver:7.0.1.37

View file

@ -2,10 +2,11 @@
"production": [
{
"dependsOn": [
"nextcloud-aio-nextcloud",
"nextcloud-aio-onlyoffice",
"nextcloud-aio-collabora",
"nextcloud-aio-clamav",
"nextcloud-aio-talk",
"nextcloud-aio-clamav"
"nextcloud-aio-nextcloud"
],
"identifier": "nextcloud-aio-apache",
"displayName": "Apache",
@ -22,7 +23,8 @@
"NEXTCLOUD_HOST=nextcloud-aio-nextcloud",
"COLLABORA_HOST=nextcloud-aio-collabora",
"TALK_HOST=nextcloud-aio-talk",
"APACHE_PORT=%APACHE_PORT%"
"APACHE_PORT=%APACHE_PORT%",
"ONLYOFFICE_HOST=nextcloud-aio-onlyoffice"
],
"volumes": [
{
@ -126,7 +128,10 @@
"AIO_URL=%AIO_URL%",
"NEXTCLOUD_MOUNT=%NEXTCLOUD_MOUNT%",
"CLAMAV_ENABLED=%CLAMAV_ENABLED%",
"CLAMAV_HOST=nextcloud-aio-clamav"
"CLAMAV_HOST=nextcloud-aio-clamav",
"ONLYOFFICE_ENABLED=%ONLYOFFICE_ENABLED%",
"COLLABORA_ENABLED=%COLLABORA_ENABLED%",
"TALK_ENABLED=%TALK_ENABLED%"
],
"maxShutdownTime": 10,
"restartPolicy": "unless-stopped"
@ -316,6 +321,27 @@
"secrets": [],
"maxShutdownTime": 10,
"restartPolicy": "unless-stopped"
},
{
"dependsOn": [],
"identifier": "nextcloud-aio-onlyoffice",
"displayName": "OnlyOffice",
"containerName": "nextcloud/aio-onlyoffice",
"ports": [],
"internalPorts": [
"80"
],
"environmentVariables": [],
"volumes": [
{
"name": "nextcloud_aio_onlyoffice",
"location": "/var/lib/onlyoffice",
"writeable": true
}
],
"secrets": [],
"maxShutdownTime": 10,
"restartPolicy": "unless-stopped"
}
]
}

View file

@ -0,0 +1,5 @@
document.addEventListener("DOMContentLoaded", function(event) {
// Collabora
var collabora = document.getElementById("collabora");
collabora.disabled = true;
});

View file

@ -0,0 +1,5 @@
document.addEventListener("DOMContentLoaded", function(event) {
// OnlyOffice
var onlyoffice = document.getElementById("onlyoffice");
onlyoffice.disabled = true;
});

View file

@ -0,0 +1,5 @@
document.addEventListener("DOMContentLoaded", function(event) {
// Talk
var talk = document.getElementById("talk");
talk.disabled = true;
});

View file

@ -87,6 +87,9 @@ $app->get('/containers', function ($request, $response, $args) use ($container)
'current_channel' => $dockerActionManger->GetCurrentChannel(),
'is_x64_platform' => $configurationManager->isx64Platform(),
'is_clamav_enabled' => $configurationManager->isClamavEnabled(),
'is_onlyoffice_enabled' => $configurationManager->isOnlyofficeEnabled(),
'is_collabora_enabled' => $configurationManager->isCollaboraEnabled(),
'is_talk_enabled' => $configurationManager->isTalkEnabled(),
]);
})->setName('profile');
$app->get('/login', function ($request, $response, $args) use ($container) {

View file

@ -11,4 +11,16 @@ document.addEventListener("DOMContentLoaded", function(event) {
// Clamav
var clamav = document.getElementById("clamav");
clamav.addEventListener('change', makeOptionsFormSubmitVisible);
// OnlyOffice
var onlyoffice = document.getElementById("onlyoffice");
onlyoffice.addEventListener('change', makeOptionsFormSubmitVisible);
// Collabora
var collabora = document.getElementById("collabora");
collabora.addEventListener('change', makeOptionsFormSubmitVisible);
// Talk
var talk = document.getElementById("talk");
talk.addEventListener('change', makeOptionsFormSubmitVisible);
});

View file

@ -53,6 +53,18 @@ class ContainerDefinitionFetcher
if (!$this->configurationManager->isClamavEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-onlyoffice') {
if (!$this->configurationManager->isOnlyofficeEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-talk') {
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
}
$ports = new ContainerPorts();
@ -111,6 +123,18 @@ class ContainerDefinitionFetcher
if (!$this->configurationManager->isClamavEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-onlyoffice') {
if (!$this->configurationManager->isOnlyofficeEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-talk') {
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
}
$dependsOn[] = $value;
}

View file

@ -36,11 +36,29 @@ class ConfigurationController
}
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!");
}
if (isset($request->getParsedBody()['clamav'])) {
$this->configurationManager->SetClamavEnabledState(1);
} else {
$this->configurationManager->SetClamavEnabledState(0);
}
if (isset($request->getParsedBody()['onlyoffice'])) {
$this->configurationManager->SetOnlyofficeEnabledState(1);
} else {
$this->configurationManager->SetOnlyofficeEnabledState(0);
}
if (isset($request->getParsedBody()['collabora'])) {
$this->configurationManager->SetCollaboraEnabledState(1);
} else {
$this->configurationManager->SetCollaboraEnabledState(0);
}
if (isset($request->getParsedBody()['talk'])) {
$this->configurationManager->SetTalkEnabledState(1);
} else {
$this->configurationManager->SetTalkEnabledState(0);
}
}
return $response->withStatus(201)->withHeader('Location', '/');

View file

@ -139,6 +139,51 @@ class ConfigurationManager
$this->WriteConfig($config);
}
public function isOnlyofficeEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isOnlyofficeEnabled']) && $config['isOnlyofficeEnabled'] === 1) {
return true;
} else {
return false;
}
}
public function SetOnlyofficeEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isOnlyofficeEnabled'] = $value;
$this->WriteConfig($config);
}
public function isCollaboraEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isCollaboraEnabled']) && $config['isCollaboraEnabled'] === 0) {
return false;
} else {
return true;
}
}
public function SetCollaboraEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isCollaboraEnabled'] = $value;
$this->WriteConfig($config);
}
public function isTalkEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isTalkEnabled']) && $config['isTalkEnabled'] === 0) {
return false;
} else {
return true;
}
}
public function SetTalkEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isTalkEnabled'] = $value;
$this->WriteConfig($config);
}
/**
* @throws InvalidSettingConfigurationException
*/

View file

@ -247,6 +247,24 @@ class DockerActionManager
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'ONLYOFFICE_ENABLED') {
if ($this->configurationManager->isOnlyofficeEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'COLLABORA_ENABLED') {
if ($this->configurationManager->isCollaboraEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} elseif ($out[1] === 'TALK_ENABLED') {
if ($this->configurationManager->isTalkEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} else {
$replacements[1] = $this->configurationManager->GetSecret($out[1]);
}

View file

@ -299,10 +299,30 @@
{% else %}
<input type="checkbox" id="clamav" name="clamav"><label for="clamav">ClamAV (only supported on x64, needs ~2GB additional RAM)</label>
{% endif %}
{% if is_collabora_enabled == true %}
<input type="checkbox" id="collabora" name="collabora" checked="checked"><label for="collabora">Collabora</label>
{% else %}
<input type="checkbox" id="collabora" name="collabora"><label for="collabora">Collabora</label>
{% endif %}
{% if is_onlyoffice_enabled == true %}
<input type="checkbox" id="onlyoffice" name="onlyoffice" checked="checked"><label for="onlyoffice">OnlyOffice (only supported on x64)</label>
{% else %}
<input type="checkbox" id="onlyoffice" name="onlyoffice"><label for="onlyoffice">OnlyOffice (only supported on x64)</label>
{% endif %}
{% if is_talk_enabled == true %}
<input type="checkbox" id="talk" name="talk" checked="checked"><label for="talk">Nextcloud Talk (needs ports 3478/TCP and 3478/UDP open)</label>
{% else %}
<input type="checkbox" id="talk" name="talk"><label for="talk">Nextcloud Talk (needs ports 3478/TCP and 3478/UDP open)</label>
{% endif %}
<input id="options-form-submit" class="button" type="submit" value="Save changes" />
</form>
{% if isAnyRunning == true or is_x64_platform == false %}
<script type="text/javascript" src="disable-clamav.js"></script>
<script type="text/javascript" src="disable-onlyoffice.js"></script>
{% endif %}
{% if isAnyRunning == true %}
<script type="text/javascript" src="disable-talk.js"></script>
<script type="text/javascript" src="disable-collabora.js"></script>
{% endif %}
{% endif %}
{% endif %}