Scripted installation of Nextcloud 29 in iocage jail

I wiped the jail and did a fresh install but it showed as an upgrade.
Sorry I’m a new user and they’ve limited my replies to 3.

I didn’t create the datasets at first as it was optional
Then tried with datasets, said corrupted jail on install.

Everything works except my login password.

I have a backup of the original jail so can revert but was hoping to update this way

Did you create the datasets as the instructions said?

Should memories video transcoding work with this? I haven’t been able to get it to work. I’m guessing it’s because go-vod doesn’t work in freebsd?

Hey, I’ve used an older version of this script about 1-2 years ago to install nextcloud in a jail on my Truenas Core system. So far, I’ve updated nextcloud via the builtin updater every once in a while but after recently updating from nextcloud 26 all the way to nextcloud 29, a wall of new warnings appeared:

  • The reverse proxy header configuration is incorrect. This is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. For more details see the [documentation :arrow_upper_right:].

  • Your web server is not properly set up to resolve .well-known URLs, failed on: /.well-known/caldav For more details see the [documentation :arrow_upper_right:].

  • 1 error in the logs since July 3, 2024, 10:47:11 PM

  • Server has no maintenance window start time configured. This means resource intensive daily background jobs will also be executed during your main usage time. We recommend to set it to a time of low usage, so users are less impacted by the load caused from these heavy tasks. For more details see the [documentation :arrow_upper_right:].

  • One or more mimetype migrations are available. Occasionally new mimetypes are added to better handle certain file types. Migrating the mimetypes take a long time on larger instances so this is not done automatically during upgrades. Use the command occ maintenance:repair --include-expensive to perform the migrations.

  • You are currently running PHP 8.0.26. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible. For more details see the [documentation :arrow_upper_right:].

  • Some headers are not set correctly on your instance - The Strict-Transport-Security HTTP header is not set (should be at least 15552000 seconds). For enhanced security, it is recommended to enable HSTS. For more details see the [documentation :arrow_upper_right:].

  • The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster. Missing optional index “oc_npushhash_di” in table “notifications_pushhash”. Missing optional index “textstep_session” in table “text_steps”. Missing optional index “fs_parent” in table “filecache”. Missing optional index “schedulobj_lastmodified_idx” in table “schedulingobjects”. Missing optional index “mounts_user_root_path_index” in table “mounts”. Missing optional index “systag_by_tagid” in table “systemtag_object_mapping”.

  • The PHP OPcache module is not properly configured. The OPcache interned strings buffer is nearly full. To assure that repeating strings can be effectively cached, it is recommended to apply “opcache.interned_strings_buffer” to your PHP configuration with a value higher than “8”… For more details see the [documentation :arrow_upper_right:].

  • You have not set or verified your email server configuration, yet. Please head over to the “Basic settings” in order to set them. Afterwards, use the “Send email” button below the form to verify your settings. For more details see the [documentation :arrow_upper_right:].

  • This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them: - sodium for Argon2 for password hashing - sysvsem For more details see the [documentation :arrow_upper_right:].

What is the easiest way to solve these problems? I’m not really confident enough to manually look into and solve each of these problems without breaking anything, as I’m not really sure how and where to even start.

I guess that a new install is the way to go here? If yes, how do I do this without losing any data? My installation was configured as recommended with one dataset named “nextcloud” and 4 sub-datasets named config, db, files and themes.

I think so.

Pull down the current version of the script and run it again. Optionally, before doing so, stop your current jail, and specify a new jail name in the config file–that way, in case there’s a problem with the new jail, you should be able to easily revert to the old one.

1 Like

One thing I’ve noticed when doing a reinstall with the script is the apps that are installed through nextcloud somehow get buggered up. They show as installed, but I usually have to reinstall them to get them to work again.

I wonder if there is a command to rescan for installed apps?

1 Like

i think i have something similar going on with the log reader app. When i did the script install, all was well. After the first update, it doesn’t work anymore as before. The symptoms are always the same after every update:

  • The security and setup warning times out - easy fix: rename the nextcloud.log file and when you redo the scan, a new file is generated and all is well.
  • Logs don’t display as they used to. No details, duplication of log entries (only in the reader, not in the file)

I have considered reinstalling the app, but didn’t so far as it a nuisance rather than an issue. The thing is, i haven’t figured out how i can reinstall the app. I only see the option to disable.

There are some apps that are considered “system apps” which you can’t uninstall, only disable.

So much for being able to fix that then…

I tried this but it does not seem to be working. I am getting the following errors after executing the script:

Reinstall detected, skipping generation of new config and database

  • [ mariadb ‘=’ mariadb ]
  • iocage exec nextcloud cp -f /mnt/includes/my.cnf /root/.my.cnf
  • iocage exec nextcloud sed -i ‘’ ‘s|mypassword|censored|’ /root/.my.cnf
  • iocage exec nextcloud su -m www -c ‘php -f /usr/local/www/nextcloud/cron.php’
    Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/nextcloud/lib/private/DB/Connection.php:163
    Stack trace:
    #0 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
    #1 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
    #2 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
    #3 /usr/local/www/nextcloud/lib/private/DB/ConnectionAdapter.php(200): Doctrine\DBAL\Connection->getDatabasePlatform()
    #4 /usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(121): OC\DB\ConnectionAdapter->getDatabasePlatform()
    #5 /usr/local/www/nextcloud/lib/private/AppConfig.php(1239): OC\DB\QueryBuilder\QueryBuilder->expr()
    #6 /usr/local/www/nextcloud/lib/private/AppConfig.php(264): OC\AppConfig->loadConfig(false)
    #7 /usr/local/www/nextcloud/lib/private/AppConfig.php(1380): OC\AppConfig->searchValues(‘enabled’, false, 2)
    #8 /usr/local/www/nextcloud/lib/private/App/AppManager.php(131): OC\AppConfig->getValues(false, ‘enabled’)
    #9 /usr/local/www/nextcloud/lib/private/App/AppManager.php(152): OC\App\AppManager->getInstalledAppsValues()
    #10 /usr/local/www/nextcloud/lib/private/legacy/OC_App.php(234): OC\App\AppManager->getInstalledApps()
    #11 /usr/local/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(90): OC_App::getEnabledApps()
    #12 /usr/local/www/nextcloud/lib/base.php(706): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
    #13 /usr/local/www/nextcloud/lib/base.php(1181): OC::init()
    #14 /usr/local/www/nextcloud/cron.php(58): require_once(‘/usr/local/www/…’)
    #15 {main}
    Command: su -m www -c php -f /usr/local/www/nextcloud/cron.php failed!
  • iocage exec nextcloud crontab -u www /mnt/includes/www-crontab
  • iocage exec nextcloud su -m www -c ‘php /usr/local/www/nextcloud/occ config:system:set maintenance_window_start --type=integer --value=5’
    An unhandled exception has been thrown:
    Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/nextcloud/lib/private/DB/Connection.php:163
    Stack trace:
    #0 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
    #1 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
    #2 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
    #3 /usr/local/www/nextcloud/lib/private/DB/ConnectionAdapter.php(200): Doctrine\DBAL\Connection->getDatabasePlatform()
    #4 /usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(121): OC\DB\ConnectionAdapter->getDatabasePlatform()
    #5 /usr/local/www/nextcloud/lib/private/AppConfig.php(1239): OC\DB\QueryBuilder\QueryBuilder->expr()
    #6 /usr/local/www/nextcloud/lib/private/AppConfig.php(264): OC\AppConfig->loadConfig(false)
    #7 /usr/local/www/nextcloud/lib/private/AppConfig.php(1380): OC\AppConfig->searchValues(‘enabled’, false, 2)
    #8 /usr/local/www/nextcloud/lib/private/App/AppManager.php(131): OC\AppConfig->getValues(false, ‘enabled’)
    #9 /usr/local/www/nextcloud/lib/private/App/AppManager.php(152): OC\App\AppManager->getInstalledAppsValues()
    #10 /usr/local/www/nextcloud/lib/private/legacy/OC_App.php(234): OC\App\AppManager->getInstalledApps()
    #11 /usr/local/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(90): OC_App::getEnabledApps()
    #12 /usr/local/www/nextcloud/lib/base.php(706): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
    #13 /usr/local/www/nextcloud/lib/base.php(1181): OC::init()
    #14 /usr/local/www/nextcloud/console.php(48): require_once(‘/usr/local/www/…’)
    #15 /usr/local/www/nextcloud/occ(11): require_once(‘/usr/local/www/…’)
    #16 {main}Command: su -m www -c php /usr/local/www/nextcloud/occ config:system:set maintenance_window_start --type=integer --value=5 failed!
  • iocage fstab -r nextcloud /root/freenas-iocage-nextcloud/includes /mnt/includes nullfs rw 0 0
    Successfully removed mount from nextcloud’s fstab
  • set +x
    Installation complete!

When trying to access nextcloud via browser, I get this error:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

My config file looks as follows:

JAIL_IP=“192.168.2.6”
DEFAULT_GW_IP=“192.168.2.1”
POOL_PATH=“/mnt/main”
TIME_ZONE=“Europe/Berlin”
HOST_NAME=“censored”
SELFSIGNED_CERT=1
COUNTRY_CODE=“DE”

What am I doing wrong? I guess I need to provide my old database root password somewhere? If so, where?

If you are running the install overtop of your existing data, then you are probably having the issue I had. Check your config.php file and make sure the dbhost line reads 'dbhost' => 'localhost:/var/run/mysql/mysql.sock',

An update a few months ago for MariaDB requires that line to change somewhat. Yours will probably read 'dbhost' => 'localhost:/var/run/mysql.sock', so make sure to change it to the above value.

1 Like

I assume that you are referring to the config.php file under “/usr/local/www/nextcloud/config”?
I just checked it and the dbhost line looks as follows:
'dbhost' => 'localhost:/tmp/mysql.sock'

I tried to change it as you explained but it does not seem to make any difference. I also cannot find a mysql.sock file under any of the mentioned paths.

UPDATE: I actually managed to get it to work now by changing the dbhost entry in the config.php file to 'dbhost' => 'localhost:/var/run/mysql/mysql.sock'. However, I also had to delete the existing my.cfg file from “/var/db/mysql/” as described here to finally get it to work. Thank you for the hint about the dbhost config!

It’s been a while since someone has had to run the script overtop an old install. But yes, that file needed to be deleted as well. Good to see you got it working.

This is very useful information. I was told that the easiest way to update php (for example from 8.2 to 8.3) would be to perform a reinstall using the script on top of the existing install.

It probably still is one of the easiest ways.
Updating php82 > php83 would require you to do a pkg install php83... and making sure you get all the original package names that are included in the script.

Hi all, just ran the script and successfully setup Nextcloud. I can access it through my FQDN on my own network after adding it to my computer’s hosts file, but I can’t seem to access it from any other network. What are the next steps? Note I have run this before and used to have it accessible from outside my network, but I moved to a new place and now everything is broken again. Would greatly appreciate insight into how to fix this!

My config is as follows:
JAIL IP=“10.0.0.36”
DEFAULT GW IP=“10.0.0.1”
POOL_PATH=“/mnt/main-storage”
TIME ZONE=“America/"
HOST_NAME="nextcloud..com"
DNS CERT=1
DNS_PLUGIN=“cloudflare”
DNS_TOKEN="
"
CERT_EMAIL="
@***.com”
COUNTRY CODE=“**”

You would have to either use a VPN to gain local access, or forward ports 80 and 443 to your nextcloud IP.

You need to make sure your domian (in cloudflare) is pointed to the right public IP. I assume you probably got a new IP when you moved from your new provider.

I just reinstall and old instalation of nextcloud script of danb35, first of all 13.2 is not available and i have to modify script to only on 13.1, then i need to put the old copied files db and config datasets on the new one, how i do it with commands on truenas, importing, how?

13.1 and 13.2 are EOL. You should probably install the BETA-2 version of CORE so you can h get a 13.3 jail running.

What eol means, i never go through betas, is secure?