Resource icon

Scripted installation of Nextcloud 28 in iocage jail 2018-03-23

Golosalex

Cadet
Joined
Sep 9, 2023
Messages
7
hi i try to use readme adn install nextcloud

i make config like this:
^o ascii code ^x search ^l undelete line ^n next li ^v next page
^u end of file ^a begin of line ^w delete word ^b back 1 char ^z next word
^t top of text ^e end of line ^r restore word ^f forward char
^c command ^d delete char ^j undelete char ESC-Enter: exit
=====line 7 col 29 lines from top 7 ===========================================
JAIL_IP="192.168.1.102"
DEFAULT_GW_IP="192.168.0.1"
POOL_PATH="/mnt/Zacroma"
TIME_ZONE="Europe/Moscow"
HOST_NAME="blabla.ru"
STANDALONE_CERT=1
CERT_EMAIL="GALEX@mail.ru"

and script fail in 5-6 sec
+ cut -f1 -d/
+ IP=192.168.1.102
+ echo 192.168.1.102
+ cut -f2 -d/
+ NETMASK=192.168.1.102
+ [ 192.168.1.102 '=' 192.168.1.102 ]
+ NETMASK=24
+ [ 24 -lt 8 ]
+ [ 24 -gt 30 ]
+ ls -A /mnt/Zacroma/nextcloud/config
ls: /mnt/Zacroma/nextcloud/config: No such file or directory
+ [ '' ]
+ cat
+ iocage create --name nextcloud -p /tmp/pkg.json -r 13.2-RELEASE 'interfaces=vnet0:bridge0' 'ip4_addr=vnet0|192.168.1.102/24' 'defaultrouter=192.168.0.1' 'boot=on' 'host_hostname=nextcloud' 'vnet=on'
nextcloud successfully created!


Stopped nextcloud due to VNET failure
+ echo 'Failed to create jail'
Failed to create jail
+ exit 1
in the first step I created a config file in sublimetext in windows by WINSCP
then i run script
then i take fail somethin like that :
JAIL_IP="192.168.1.102\r" - bad char
then i remove jail nextcloud and edit config in "ee" utilite
then i try script and fail
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
JAIL_IP="192.168.1.102"
DEFAULT_GW_IP="192.168.0.1"
This isn't going to work--your default gateway needs to be in the same subnet as the jail's IP. If you're using a larger subnet than /24, you'll need to specify that with the jail IP, e.g., JAIL_IP="192.168.1.102/22".
JAIL_IP="192.168.1.102\r" - bad char
This is a common result of editing the file on Windows. You'd need to use an editor that can use Unix line endings, like Notepad++ or VSCode. Or just create/edit the file on the NAS with something like ee or nano.
 

Golosalex

Cadet
Joined
Sep 9, 2023
Messages
7
This isn't going to work--your default gateway needs to be in the same subnet as the jail's IP
Ups! It's my mistake. thanks for the help. it was great.
is there brute force protection?
When I try to login multiple times, I experience a longer and longer response time.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

bnorman93

Dabbler
Joined
May 3, 2022
Messages
17

Try reading this.

Make sure to read it all. There are two steps to it.
1. Deleting the my.cnf file
2. Changing the value of 'db' in your config.php

Then you can reinstall.
Thank you i must of been really wore out... I ended up deleting everything and reinstalling everything and fixed it as well as making sure the cnf file actually had the right location because i changed the name of it in my pool for some unknown reason before i got a response but i ended up falling asleep finally got a chance to reply
 

GJSchaller

Contributor
Joined
Feb 10, 2021
Messages
100
Suggested addition - an option in the config to automatically add the following line to the crontab for user www:

Code:
*/5 * * * * php -f /usr/local/www/nextcloud/cron.php


Whenever I recreate the jail, I forget to add this back into the crontab until a few days later - having this as an option to be added automatically would be nice.

Thank you!
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Suggested addition - an option in the config to automatically add the following line to the crontab for user www:

Code:
*/5 * * * * php -f /usr/local/www/nextcloud/cron.php


Whenever I recreate the jail, I forget to add this back into the crontab until a few days later - having this as an option to be added automatically would be nice.

Thank you!
What does this do?
Cron is added around line 550 of the script?
Does that not do what you want it to?
 
Joined
Aug 12, 2021
Messages
6
Hello!

I've had a Nextcloud jail running flawlessly for years thanks to your script!
But updating the poll app has failed and left my web interface in the update-error loop in the images below.

I've been directed to this issue which should be a solution: https://github.com/nextcloud/polls/issues/3067
But can't figure out what to do. The commands in the thread doesn't seem to give me the same results and wondered if it is because there's differences in FreeBSD that I'm overlooking.

Any help is appreciated!

https://camo.githubusercontent.com/ac7b8a652e7fa9f4815925daf89aec8f902b80e3a720fd9270f96f192e7d1611/68747470733a2f2f692e696d6775722e636f6d2f354447455a53482e706e67

https://camo.githubusercontent.com/41f5f4852db17a4ce5e9a4e4de90c8839ddb91f141a5541e6d33f50403092ee1/68747470733a2f2f692e696d6775722e636f6d2f6d6e3579715a502e706e67
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Hello!

I've had a Nextcloud jail running flawlessly for years thanks to your script!
But updating the poll app has failed and left my web interface in the update-error loop in the images below.

I've been directed to this issue which should be a solution: https://github.com/nextcloud/polls/issues/3067
But can't figure out what to do. The commands in the thread doesn't seem to give me the same results and wondered if it is because there's differences in FreeBSD that I'm overlooking.

Any help is appreciated!

https://camo.githubusercontent.com/ac7b8a652e7fa9f4815925daf89aec8f902b80e3a720fd9270f96f192e7d1611/68747470733a2f2f692e696d6775722e636f6d2f354447455a53482e706e67

https://camo.githubusercontent.com/41f5f4852db17a4ce5e9a4e4de90c8839ddb91f141a5541e6d33f50403092ee1/68747470733a2f2f692e696d6775722e636f6d2f6d6e3579715a502e706e67
You could try disabling the polls app to begin with using this command.
su -m www -c 'php /usr/local/www/nextcloud/occ app:disable polls'
Then try the update again, and reenable polls after.
Or try removing it by replacing 'disable' with 'remove' in the above command.
Or perhaps doing an 'update polls' first.
 

tsf-freenas

Cadet
Joined
Dec 16, 2019
Messages
4
Hi, I've tried using this script to install Nextcloud a few times now with different options before finally going barebones and using most of the defaults. Same error is thrown each time.

Install gets just about all the way to the end before giving the error below:
----------------------------------------------------------------
+ echo 'PostgreSQL root password is [redacted]'
+ echo 'Nextcloud database password is [redacted]'
+ echo 'Nextcloud Administrator password is [redacted]'
+ iocage exec nextcloud mkdir -p /var/log/nextcloud/
+ iocage exec nextcloud chown www:www /var/log/nextcloud
+ [ pgsql '=' mariadb ]
+ [ pgsql '=' pgsql ]
+ iocage exec nextcloud su -m www -c 'php /usr/local/www/nextcloud/occ maintenance:install --database="pgsql" --database-name="nextcloud" --database-user="nextcloud" --database-pass="[redacted]" --database-host="localhost:/tmp/.s.PGSQL.5432" --admin-user="admin" --admin-pass="[redacted]" --data-dir="/mnt/files"'
No database drivers (sqlite, mysql, or postgresql) installed.


An unhandled exception has been thrown:

Exception: Environment not properly prepared. in /usr/local/www/nextcloud/lib/private/Console/Application.php:167
Stack trace:
#0 /usr/local/www/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /usr/local/www/nextcloud/occ(11): require_once('/usr/local/www/...')
#2 {main}Command: su -m www -c php /usr/local/www/nextcloud/occ maintenance:install --database="pgsql" --database-name="nextcloud" --database-user="nextcloud" --database-pass="[redacted]" --database-host="localhost:/tmp/.s.PGSQL.5432" --admin-user="admin" --admin-pass="[redacted]" --data-dir="/mnt/files" failed!
+ echo 'Failed to install Nextcloud, aborting'
Failed to install Nextcloud, aborting
+ exit 1
----------------------------------------------------------------

Config file used for most recent attempt:
----------------------------------------------------------------
JAIL_IP="[redacted]"
DEFAULT_GW_IP="[redacted]"
POOL_PATH="/mnt/FourD_RaidZ1/iocage/jails"
DATABASE="pgsql"
TIME_ZONE="America/New_York"
HOST_NAME="[redacted]"
SELFSIGNED_CERT=1
CERT_EMAIL="[redacted]"
----------------------------------------------------------------

Thanks in advance for any guidance. And thanks @danb35 for your hard work on this.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I'll see what I can find. I normally use MySQL/MariaDB rather than Postgres, so the parts that are unique to Postgres are relatively untested.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I don't know why not, though as I indicated above I don't have much experience with pgsql. But since it looks like that part of the script is going to take some work anyway...
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
It could also be the php82 update, as that is fairly recent, and I have not seen this issue pop up until now. But I'll leave you to it as I don't have access to my test environment right now.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

tsf-freenas

Cadet
Joined
Dec 16, 2019
Messages
4
...or it may be that pgsql is now too old for the PHP package to work with it. From https://www.freshports.org/databases/php82-pgsql:

Changing the script to install pgsql15 (and remove the -q flag) and re-running it; let's see what this does.
Thanks for the suggestion.

I adjusted the script as recommended:
----------------------------------------------------------------
if [ "${DATABASE}" = "mariadb" ]; then
iocage exec "${JAIL_NAME}" pkg install -qy mariadb106-server php82-pdo_mysql php82-mysqli
elif [ "${DATABASE}" = "pgsql" ]; then
iocage exec "${JAIL_NAME}" pkg install -y postgresql15-server php82-pgsql php82-pdo_pgsql
fi
----------------------------------------------------------------

I did get a bit farther but then failed again with the following:
----------------------------------------------------------------
Command: su -m postgres -c /usr/local/bin/pg_ctl -D /var/db/postgres/data12 start failed!
+ iocage exec nextcloud sed -i '' 's|mypassword|HT/HKlP8T/9+A0E655QlBg==|' /root/.pgpass
+ iocage exec nextcloud psql -U postgres -c 'CREATE DATABASE nextcloud;'
jexec: postgres: no such user
Command: psql -c CREATE DATABASE nextcloud; failed!
+ echo 'Failed to create PostgreSQL database, aborting'
Failed to create PostgreSQL database, aborting

+ exit 1
----------------------------------------------------------------

The main reason I had chosen to the use PostgreSQL is because I had seen it being used with other installations and wasn't aware that it had not been tested here. Then tried your suggestion to adjust the install script just in case it ended up working. However, since it didn't, I reviewed your initial response that you typically use mariadb and chose to go back and try that and it did install successfully. So I think I'm going to stay with that install method at this time since I am short on time and need to get this installed and running.

Thank you again for the quick response and suggestion.
 

RedPull

Dabbler
Joined
Aug 27, 2016
Messages
17
Hello there,

A wonderfull script, i must say!
Installed perfectly with no issues at all.
However, when i try to remove the "staging flag" by running
Code:
iocage exec nextcloud /root/remove-staging.sh

response is:
Code:
2023/09/18 17:32:18.939 INFO    using provided configuration    {"config_file":
"/usr/local/www/Caddyfile", "config_adapter": "caddyfile"}


browser ssl details:
Code:
Common Name (CN) (STAGING) Ersatz Edamame E1
Organization (O) (STAGING) Let's Encrypt
Organizational Unit (OU) <Not part of certificate>


here is how my nextcloud-config file looks like
Code:
JAIL_NAME="nextcloud"
JAIL_IP="10.1.1.10"
DEFAULT_GW_IP="10.1.1.1"
POOL_PATH="/mnt/tank"
DB_PATH="/mnt/tank/apps/nextcloud/db"
CONFIG_PATH="/mnt/tank/apps/nextcloud/config"
THEMES_PATH="/mnt/tank/apps/nextcloud/themes"
FILES_PATH="/mnt/tank/cloud"
TIME_ZONE="Europe/Brussels"
COUNTRY_CODE="BE"
HOST_NAME="cloud.domain.be"
DNS_CERT=1
DNS_PLUGIN="cloudflare"
DNS_TOKEN="*****************************"
CERT_EMAIL="name@domain.be"


And i got my DNS_TOKEN by folowing these instructions https://github.com/libdns/cloudflare

What am i missing here?
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Hello there,

A wonderfull script, i must say!
Installed perfectly with no issues at all.
However, when i try to remove the "staging flag" by running
Code:
iocage exec nextcloud /root/remove-staging.sh

response is:
Code:
2023/09/18 17:32:18.939 INFO    using provided configuration    {"config_file":
"/usr/local/www/Caddyfile", "config_adapter": "caddyfile"}


browser ssl details:
Code:
Common Name (CN) (STAGING) Ersatz Edamame E1
Organization (O) (STAGING) Let's Encrypt
Organizational Unit (OU) <Not part of certificate>


here is how my nextcloud-config file looks like
Code:
JAIL_NAME="nextcloud"
JAIL_IP="10.1.1.10"
DEFAULT_GW_IP="10.1.1.1"
POOL_PATH="/mnt/tank"
DB_PATH="/mnt/tank/apps/nextcloud/db"
CONFIG_PATH="/mnt/tank/apps/nextcloud/config"
THEMES_PATH="/mnt/tank/apps/nextcloud/themes"
FILES_PATH="/mnt/tank/cloud"
TIME_ZONE="Europe/Brussels"
COUNTRY_CODE="BE"
HOST_NAME="cloud.domain.be"
DNS_CERT=1
DNS_PLUGIN="cloudflare"
DNS_TOKEN="*****************************"
CERT_EMAIL="name@domain.be"


And i got my DNS_TOKEN by folowing these instructions https://github.com/libdns/cloudflare

What am i missing here?
Check your Caddyfile at /usr/local/www/Caddyfile

There is a line at the very top that start with acme_ca Make sure it is commented out, then do service caddy restart or it could also be that your browser has cached the old cert. Try clearing the cache if the above doesn't work.
 

RedPull

Dabbler
Joined
Aug 27, 2016
Messages
17
Check your Caddyfile at /usr/local/www/Caddyfile

There is a line at the very top that start with acme_ca Make sure it is commented out, then do service caddy restart or it could also be that your browser has cached the old cert. Try clearing the cache if the above doesn't work.
victort, My man! service caddy restart did the trick. TYVM!
 

GJSchaller

Contributor
Joined
Feb 10, 2021
Messages
100
What does this do?
Cron is added around line 550 of the script?
Does that not do what you want it to?

Nextcloud needs cron.php called on a regular basis - the suggested method is to have a local cron job run every 5 minutes, calling that file as the user www. When the jail is installed, the cron job is not scheduled by default, or at least not as www.

After recreating the Jail, I usually do a "crontab -e -u www" and add the call to cron.php to run every 5 minutes. I don't see that job created by default when the jail is created.
 
Top