diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 067876f481..c1122d2047 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -56,6 +56,7 @@ public function getForm(): TemplateResponse { 'web_server' => strtolower($_SERVER['SERVER_SOFTWARE']), 'os_family' => PHP_VERSION_ID >= 70200 ? PHP_OS_FAMILY : PHP_OS, 'platform' => php_uname('m'), + 'is_snap' => $this->isSnapInstallation(), 'fonts' => $this->fontService->getFontFileNames(), 'esignature_base_url' => $this->config->getAppValue('richdocuments', 'esignature_base_url'), 'esignature_client_id' => $this->config->getAppValue('richdocuments', 'esignature_client_id'), @@ -77,4 +78,13 @@ public function getSection(): string { public function getPriority(): int { return 0; } + + private function isSnapInstallation(): bool { + $snap = getenv('SNAP'); + if ($snap !== false && $snap !== '') { + return true; + } + + return str_starts_with((string)$this->config->getSystemValue('datadirectory', ''), '/var/snap/nextcloud/'); + } } diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 9f8c331ec8..cd18537217 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -125,7 +125,7 @@
{{ t('richdocuments', 'If the installation from the App Store fails, you can still do that manually using this command:') }} - php -d memory_limit=512M occ app:install {{ CODEAppID }} + {{ CODEInstallCommand }}
@@ -491,6 +491,7 @@ export default { errorMessage: null, hostErrors: [window.location.host === 'localhost' || window.location.host === '127.0.0.1', window.location.protocol !== 'https:', false], demoServers: null, + isSnap: false, CODEInstalled: 'richdocumentscode' in OC.appswebroots, CODECompatible: true, CODEAppID: 'richdocumentscode', @@ -572,6 +573,15 @@ export default { callbackUrl() { return this.settings.wopi_callback_url ? this.settings.wopi_callback_url : getCallbackBaseUrl() }, + CODEInstallCommand() { + return this.isSnap ? this.snapCODEInstallCommand : this.manualCODEInstallCommand + }, + manualCODEInstallCommand() { + return `php -d memory_limit=512M occ app:install ${this.CODEAppID}` + }, + snapCODEInstallCommand() { + return `sudo nextcloud.occ app:install ${this.CODEAppID}` + }, }, watch: { 'settings.public_wopi_url'(newVal, oldVal) { @@ -623,6 +633,7 @@ export default { this.uiVisible.external_apps = !!(this.settings.external_apps && this.settings.external_apps !== '') this.demoServers = this.initial.demo_servers + this.isSnap = this.initial.is_snap === true if (this.initial.web_server && this.initial.web_server.length > 0) { this.isNginx = this.initial.web_server.indexOf('nginx') !== -1