php occ config:system:set objectstore class --value=OC\\Files\\ObjectStore\\S3
php occ config:system:set objectstore arguments autocreate --type=boolean --value=true
php occ config:system:set objectstore arguments bucket --value=$bucket_name
php occ config:system:set objectstore arguments key --value=$key
php occ config:system:set objectstore arguments secret --value=$secret
php occ config:system:set objectstore arguments hostname --value=$hostname
php occ config:system:set objectstore arguments region --value=$region
php occ config:system:set objectstore arguments port --type=integer --value=443
php occ config:system:set objectstore arguments use_ssl --type=boolean --value=true
php occ config:system:set objectstore arguments use_path_style --type=boolean --value=false
We should get the S3 config setup
We get the following stacktrace if I run the commands in order (right after the first command):
Exception: Access Key, Secret and Bucket have to be configured. in /var/www/nc/nextcloud/lib/private/Files/ObjectStore/S3ConnectionTrait.php:52
Stack trace:
#0 /var/www/nc/nextcloud/lib/private/Files/ObjectStore/S3.php(34): OC\Files\ObjectStore\S3->parseParams(Array)
#1 /var/www/nc/nextcloud/lib/private/legacy/util.php(118): OC\Files\ObjectStore\S3->__construct(Array)
#2 /var/www/nc/nextcloud/lib/private/legacy/util.php(292): OC_Util::initObjectStoreRootFS(Array)
#3 /var/www/nc/nextcloud/lib/private/Files/Filesystem.php(266): OC_Util::setupFS('')
#4 /var/www/nc/nextcloud/lib/private/Server.php(288): OC\Files\Filesystem::getMountManager(NULL)
#5 /var/www/nc/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#6 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('RootFolder')
#7 /var/www/nc/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('RootFolder')
#8 /var/www/nc/nextcloud/lib/private/Server.php(310): OC\ServerContainer->query('RootFolder')
#9 [internal function]: OC\Server->OC\{closure}()
#10 /var/www/nc/nextcloud/lib/private/Files/Node/LazyRoot.php(61): call_user_func(Object(Closure))
#11 /var/www/nc/nextcloud/lib/private/Files/Node/LazyRoot.php(141): OC\Files\Node\LazyRoot->__call('get', Array)
#12 /var/www/nc/nextcloud/lib/private/Files/AppData/AppData.php(81): OC\Files\Node\LazyRoot->get('appdata_ocs4zbn...')
#13 /var/www/nc/nextcloud/lib/private/Files/AppData/AppData.php(107): OC\Files\AppData\AppData->getAppDataFolder()
#14 /var/www/nc/nextcloud/lib/private/Template/IconsCacher.php(78): OC\Files\AppData\AppData->getFolder('icons')
#15 [internal function]: OC\Template\IconsCacher->__construct(Object(OC\Log), Object(OC\Files\AppData\Factory), Object(OC\URLGenerator), Object(OC\AppFramework\Utility\TimeFactory))
#16 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): ReflectionClass->newInstanceArgs(Array)
#17 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#18 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Template\\Ico...')
#19 /var/www/nc/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Template\\Ico...')
#20 /var/www/nc/nextcloud/lib/private/Server.php(980): OC\ServerContainer->query('OC\\Template\\Ico...')
#21 /var/www/nc/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#22 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\Template\\SCS...')
#23 /var/www/nc/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Template\\SCS...')
#24 /var/www/nc/nextcloud/lib/private/Repair.php(145): OC\ServerContainer->query('OC\\Template\\SCS...')
#25 /var/www/nc/nextcloud/core/register_command.php(143): OC\Repair::getRepairSteps()
#26 /var/www/nc/nextcloud/lib/private/Console/Application.php(118): require_once('/var/www/nc/nex...')
#27 /var/www/nc/nextcloud/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /var/www/nc/nextcloud/occ(11): require_once('/var/www/nc/nex...')
We get the following stacktrace if I run the last command first (changing the order):
Error: Class name must be a valid object or a string in /var/www/nc/nextcloud/lib/private/legacy/util.php:118
Stack trace:
#0 /var/www/nc/nextcloud/lib/private/legacy/util.php(292): OC_Util::initObjectStoreRootFS(Array)
#1 /var/www/nc/nextcloud/lib/private/Files/Filesystem.php(266): OC_Util::setupFS('')
#2 /var/www/nc/nextcloud/lib/private/Server.php(288): OC\Files\Filesystem::getMountManager(NULL)
#3 /var/www/nc/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#4 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('RootFolder')
#5 /var/www/nc/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('RootFolder')
#6 /var/www/nc/nextcloud/lib/private/Server.php(310): OC\ServerContainer->query('RootFolder')
#7 [internal function]: OC\Server->OC\{closure}()
#8 /var/www/nc/nextcloud/lib/private/Files/Node/LazyRoot.php(61): call_user_func(Object(Closure))
#9 /var/www/nc/nextcloud/lib/private/Files/Node/LazyRoot.php(141): OC\Files\Node\LazyRoot->__call('get', Array)
#10 /var/www/nc/nextcloud/lib/private/Files/AppData/AppData.php(81): OC\Files\Node\LazyRoot->get('appdata_ocs4zbn...')
#11 /var/www/nc/nextcloud/lib/private/Files/AppData/AppData.php(107): OC\Files\AppData\AppData->getAppDataFolder()
#12 /var/www/nc/nextcloud/lib/private/Template/IconsCacher.php(78): OC\Files\AppData\AppData->getFolder('icons')
#13 [internal function]: OC\Template\IconsCacher->__construct(Object(OC\Log), Object(OC\Files\AppData\Factory), Object(OC\URLGenerator), Object(OC\AppFramework\Utility\TimeFactory))
#14 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(81): ReflectionClass->newInstanceArgs(Array)
#15 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#16 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Template\\Ico...')
#17 /var/www/nc/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Template\\Ico...')
#18 /var/www/nc/nextcloud/lib/private/Server.php(980): OC\ServerContainer->query('OC\\Template\\Ico...')
#19 /var/www/nc/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#20 /var/www/nc/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\Template\\SCS...')
#21 /var/www/nc/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Template\\SCS...')
#22 /var/www/nc/nextcloud/lib/private/Repair.php(145): OC\ServerContainer->query('OC\\Template\\SCS...')
#23 /var/www/nc/nextcloud/core/register_command.php(143): OC\Repair::getRepairSteps()
#24 /var/www/nc/nextcloud/lib/private/Console/Application.php(118): require_once('/var/www/nc/nex...')
#25 /var/www/nc/nextcloud/console.php(95): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /var/www/nc/nextcloud/occ(11): require_once('/var/www/nc/nex...')
Operating system: Linux, Debian 9.5
Web server: nginx, but irrelevant
Database: postgresql, but irrelevant
PHP version: PHP 7.0.33-0+deb9u1 (cli) (built: Dec 7 2018 11:36:49) ( NTS )
Nextcloud version: 15.0.4
Updated from an older Nextcloud/ownCloud or fresh install: Fresh install
Where did you install Nextcloud from: Tarball downloaded from the website
Signing status:
Signing status
Inaccessible at present
List of activated apps:
App list
As default:
Enabled:
- accessibility: 1.1.0
- activity: 2.8.2
- cloud_federation_api: 0.1.0
- comments: 1.5.0
- dav: 1.8.1
- federatedfilesharing: 1.5.0
- federation: 1.5.0
- files: 1.10.0
- files_pdfviewer: 1.4.0
- files_sharing: 1.7.0
- files_texteditor: 2.7.0
- files_trashbin: 1.5.0
- files_versions: 1.8.0
- files_videoplayer: 1.4.0
- firstrunwizard: 2.4.0
- gallery: 18.2.0
- logreader: 2.0.0
- lookup_server_connector: 1.3.0
- nextcloud_announcements: 1.4.0
- notifications: 2.3.0
- oauth2: 1.3.0
- password_policy: 1.5.0
- provisioning_api: 1.5.0
- serverinfo: 1.5.0
- sharebymail: 1.5.0
- support: 1.0.0
- survey_client: 1.3.0
- systemtags: 1.5.0
- theming: 1.6.0
- twofactor_backupcodes: 1.4.1
- updatenotification: 1.5.0
- workflowengine: 1.5.0
Disabled:
- admin_audit
- encryption
- files_external
- user_ldap
Nextcloud configuration:
Config report
{
"system": {
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"localhost"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "pgsql",
"version": "15.0.4.0",
"overwrite.cli.url": "http:\/\/localhost",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"instanceid": "***REMOVED SENSITIVE VALUE***",
"memcache.local": "\\OC\\Memchache\\APCu"
}
}
Are you using external storage, if yes which one: trying to setup external primary storage on S3 from a default installation
Are you using encryption: no
Are you using an external user-backend, if yes which one: Nope
You can't setup S3 after your installation. S3 as primary has to be setup before you install
Which is great, except modifying the system configuration via occ is not available until nextcloud is installed. What other people online do is write a hacky line of sed script, to manually force nextcloud to use alternate primary storage.
You can just edit your config.php with your favorite editor. You have todo it only once anyway.
In this case part of the magic is I need to do it automatically from a shell script. I can do it, but I was hoping to use the convenience functions in occ to make it safer.
If you generate the configuration by some provision script it might be easier to place it in another file (e.g. objectstore.config.php).
https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file
With the multiple file approach, I no longer need the above occ commands. I can do without them. I don't know if it's an issue that you can't set configuration before installation, or not. I can close this issue, since my actual issue has been solved, or I can rename to reflect the limited configuration possible before installation.
I can close this issue, since my actual issue has been solved
Closing this now. Please file new tickets for any other bugs you may have found!
Most helpful comment
If you generate the configuration by some provision script it might be easier to place it in another file (e.g.
objectstore.config.php).https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file