danb35 / freenas-iocage-nextcloud

Script to create an iocage jail on FreeNAS for the latest Nextcloud 28 release, including Caddy, MariaDB or PostgreSQL, and Let's Encrypt
GNU General Public License v3.0
250 stars 71 forks source link

'Failed to download Nextcloud' #210

Closed mattmichaels closed 6 months ago

mattmichaels commented 7 months ago

Had an issue so I tried to run a reinstall.

Getting 'Failed to download Nextcloud'. Tried to specify Nextcloud version 26 instead of 27 to fix but getting the same result leaving default or trying prior version. Latest release of TrueNAS CORE installed.

go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: downloading github.com/jmespath/go-jmespath v0.4.0
2023/12/08 19:51:38 [INFO] exec (timeout=0s): /usr/local/bin/go build -o /usr/local/bin/caddy -ldflags -w -s -trimpath
2023/12/08 19:52:17 [INFO] Build complete: /usr/local/bin/caddy
2023/12/08 19:52:17 [INFO] Cleaning up temporary folder: /tmp/buildenv_2023-12-08-1950.1052236604
+ FILE=latest-26.tar.bz2
+ iocage exec nextcloud fetch -o /tmp https://download.nextcloud.com/server/releases/latest-26.tar.bz2 https://download.nextcloud.com/server/releases/latest-26.tar.bz2.asc https://nextcloud.com/nextcloud.asc
/tmp/latest-26.tar.bz2                                 152 MB 9785 kBps    16s
/tmp/latest-26.tar.bz2.asc                             833  B 9804 kBps    00s
fetch: https://nextcloud.com/nextcloud.asc: Not Found
Command: fetch -o /tmp https://download.nextcloud.com/server/releases/latest-26.tar.bz2 https://download.nextcloud.com/server/releases/latest-26.tar.bz2.asc https://nextcloud.com/nextcloud.asc failed!
+ echo 'Failed to download Nextcloud'
Failed to download Nextcloud
+ exit 1

edit - looks like https://nextcloud.com/nextcloud.asc results in a '404 - Page not found'?

RafalLukawiecki commented 7 months ago

This issue is caused by the unexpected removal of the Nextcloud PGP key from their main web site. I am currently preparing a workaround that uses public PGP key server. It should be ready later today, I will submit a PR.

RafalLukawiecki commented 7 months ago

See #211

mattmichaels commented 7 months ago

Hi - thanks for your fast PR.

I tried to run this but got an error creating the jail

(sorry if this is a duplicate comment, i posted and i don't see the original!)

root@freenas:/mnt/NAS-pool/temp/freenas-iocage-nextcloud # sh nextcloud-jail.sh                                                               
JAIL_INTERFACES not set, defaulting to: vnet0:bridge0
Existing Nextcloud config detected... Checking Database compatibility for reinst                                                              all
Database is compatible, continuing...
 is not a valid property!
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_create.py", line 496, in _create_jail
    value, config = iocjson.json_check_prop(key, value, config)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_json.py", line 2501, in json_check_prop
    iocage_lib.ioc_common.logit(
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_common.py", line 107, in logit
    callback(content, exception)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_common.py", line 94, in callback
    raise SystemExit(1)
SystemExit: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/zfs.py", line 20, in run
    cp.check_returncode()
  File "/usr/local/lib/python3.9/subprocess.py", line 460, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['zfs', 'destroy', '-r', '-Rf', 'SSD/iocage/jails/nextcloud/root']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/iocage", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/iocage_cli/create.py", line 222, in cli
    iocage.create(release, props, count, pkglist=pkglist,
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/iocage.py", line 603, in create
    ioc_create.IOCCreate(
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_create.py", line 101, in create_jail
    return self._create_jail(jail_uuid, location)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_create.py", line 505, in _create_jail
    iocage_lib.ioc_destroy.IOCDestroy().destroy_jail(location)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_destroy.py", line 280, in destroy_jail
    self.__destroy_parse_datasets__(
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_destroy.py", line 256, in __destroy_parse_datasets__
    self.__destroy_dataset__(dataset)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/ioc_destroy.py", line 169, in __destroy_dataset__
    ds.destroy(recursive=True, force=True)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/dataset.py", line 98, in destroy
    return destroy_zfs_resource(self.resource_name, recursive, force)
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/zfs.py", line 187, in destroy_zfs_resource
    return run([*cmd, resource]).returncode == 0
  File "/usr/local/lib/python3.9/site-packages/iocage_lib/zfs.py", line 22, in run
    raise ZFSException(cp.returncode, cp.stderr)
iocage_lib.zfs.ZFSException: cannot destroy 'SSD/iocage/jails/nextcloud/root': dataset is busy

Failed to create jail
RafalLukawiecki commented 7 months ago

May I suggest that you uncomment line 5 in the script, so it says set -x then run again? It will echo all the statements up to the one that causes the process to fail. It should help clarify what is causing the new issue that you have just encountered.

mattmichaels commented 7 months ago
+ echo 'Database is compatible, continuing...'
Database is compatible, continuing...
+ REINSTALL=true
+ cat
+ [ false '=' true ]
+ JAIL_TYPE_OPTION=''
+ iocage create --name nextcloud -p /tmp/pkg.json -r 12.2-RELEASE 'interfaces=vnet0:bridge0' 'ip4_addr=vnet0|192.168.0.4/24' 'defaultrouter=192.168.0.1' 'boot=on' 'host_hostname=nextcloud' 'vnet=on' ''
 is not a valid property!
+ echo 'Failed to create jail'
Failed to create jail
+ exit 1
RafalLukawiecki commented 7 months ago

Thank you for the output. The way I was quoting a parameter was not acceptable to iocage. I have corrected it, and I have updated PR #211. Hopefully it will work for you now. Please let me know either way.

mattmichaels commented 7 months ago

here's the output (aside from removing the pasted DB password and my email and server address)

go: downloading github.com/googleapis/enterprise-certificate-proxy v0.2.5
go: downloading cloud.google.com/go/compute v1.23.0
go: downloading github.com/jmespath/go-jmespath v0.4.0
go: downloading google.golang.org/appengine v1.6.7
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
2023/12/10 18:33:37 [INFO] exec (timeout=0s): /usr/local/bin/go build -o /usr/local/bin/caddy -ldflags -w -s -trimpath
2023/12/10 18:34:25 [INFO] Build complete: /usr/local/bin/caddy
2023/12/10 18:34:25 [INFO] Cleaning up temporary folder: /tmp/buildenv_2023-12-10-1832.1874640847
+ FILE=latest-27.tar.bz2
+ iocage exec nextcloud fetch -o /tmp https://download.nextcloud.com/server/releases/latest-27.tar.bz2 https://download.nextcloud.com/server/releases/latest-27.tar.bz2.asc
/tmp/latest-27.tar.bz2                                 174 MB   10 MBps    16s
/tmp/latest-27.tar.bz2.asc                             833  B 6837 kBps    00s
+ iocage exec nextcloud fetch -o /tmp https://nextcloud.com/nextcloud.asc
fetch: https://nextcloud.com/nextcloud.asc: Not Found
Command: fetch -o /tmp https://nextcloud.com/nextcloud.asc failed!
+ iocage exec nextcloud gpg --keyserver pgpkeys.eu --recv-key 28806A878AE423A28372792ED75899B9A724937A
gpg: Warning: using insecure memory!
gpg: directory '/root/.gnupg' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D75899B9A724937A: public key "Nextcloud Security <security@nextcloud.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
+ iocage exec nextcloud gpg --verify /tmp/latest-27.tar.bz2.asc
gpg: Warning: using insecure memory!
gpg: assuming signed data in '/tmp/latest-27.tar.bz2'
gpg: Signature made Thu Nov 23 12:57:02 2023 EST
gpg:                using RSA key 28806A878AE423A28372792ED75899B9A724937A
gpg: Good signature from "Nextcloud Security <security@nextcloud.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 2880 6A87 8AE4 23A2 8372  792E D758 99B9 A724 937A
+ iocage exec nextcloud tar xjf /tmp/latest-27.tar.bz2 -C /usr/local/www/
+ iocage exec nextcloud chown -R www:www /usr/local/www/nextcloud/
+ [ mariadb '=' mariadb ]
+ iocage exec nextcloud sysrc 'mysql_enable=YES'
mysql_enable:  -> YES
+ iocage exec nextcloud sysrc 'redis_enable=YES'
redis_enable:  -> YES
+ iocage exec nextcloud sysrc 'php_fpm_enable=YES'
php_fpm_enable:  -> YES
+ [ 0 -eq 1 ]
+ iocage exec nextcloud cp -f /mnt/includes/php.ini /usr/local/etc/php.ini
+ iocage exec nextcloud chown -R www:www /usr/local/etc/php.ini
+ iocage exec nextcloud cp -f /mnt/includes/redis.conf /usr/local/etc/redis.conf
+ iocage exec nextcloud cp -f /mnt/includes/www.conf /usr/local/etc/php-fpm.d/
+ [ 0 -eq 1 ]
+ [ 1 -eq 1 ]
+ iocage exec nextcloud cp -f /mnt/includes/remove-staging.sh /root/
+ [ 0 -eq 1 ]
+ [ 0 -eq 1 ]
+ [ 1 -eq 1 ]
+ echo $'Copying Caddyfile for Let\'s Encrypt DNS cert'
Copying Caddyfile for Let's Encrypt DNS cert
+ iocage exec nextcloud cp -f /mnt/includes/Caddyfile-dns /usr/local/www/Caddyfile
+ iocage exec nextcloud cp -f /mnt/includes/caddy /usr/local/etc/rc.d/
+ [ mariadb '=' mariadb ]
+ iocage exec nextcloud cp -f /mnt/includes/my-system.cnf /usr/local/etc/mysql/conf.d/nextcloud.cnf
+ iocage exec nextcloud sed -i '' s/yourhostnamehere/xxxxxxx/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/dns_plugin/cloudflare/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/api_token// /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/jail_ip/192.168.0.4/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' s/youremailhere/xxxxxx@gmail.com/ /usr/local/www/Caddyfile
+ iocage exec nextcloud sed -i '' 's|mytimezone|America/New_York|' /usr/local/etc/php.ini
+ iocage exec nextcloud sysrc 'caddy_enable=YES'
caddy_enable:  -> YES
+ iocage exec nextcloud sysrc 'caddy_config=/usr/local/www/Caddyfile'
caddy_config:  -> /usr/local/www/Caddyfile
+ iocage restart nextcloud
* Stopping nextcloud
  + Executing prestop OK
  + Stopping services OK
  + Tearing down VNET OK
  + Removing devfs_ruleset: 1005 OK
  + Removing jail process OK
  + Executing poststop OK
No default gateway found for ipv6.
* Starting nextcloud
  + Started OK
  + Using devfs_ruleset: 1005 (iocage generated default)
  + Configuring VNET OK
  + Using IP options: vnet
  + Starting services OK
  + Executing poststart OK
+ iocage exec nextcloud touch /var/log/nextcloud.log
+ iocage exec nextcloud chown www /var/log/nextcloud.log
+ iocage exec nextcloud pw usermod www -G redis
+ iocage exec nextcloud chmod 777 /var/run/redis/redis.sock
+ [ true '==' true ]
+ echo 'Reinstall detected, skipping generation of new config and database'
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|xxxxxxxxxxxxxxxxxxx==|' /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:140
Stack trace:
#0 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doc                             trine\DBAL\Connection->getWrappedConnection()
#2 /usr/local/www/nextcloud/lib/private/DB/Connection.php(262): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM `...', Array, Array, NULL)
#3 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery('SELECT * FROM `...', Array, Array)
#4 /usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): D                                 octrine\DBAL\Query\QueryBuilder->execute()
#5 /usr/local/www/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /usr/local/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /usr/local/www/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /usr/local/www/nextcloud/lib/private/legacy/OC_App.php(803): OC\AppConfig->getValues(false, 'installed_versi...')
#9 /usr/local/www/nextcloud/lib/private/Server.php(736): OC_App::getAppVersions()
#10 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#11 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#12 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OC\\Memcache\\Fac...')
#13 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query('OC\\Memcache\\Fac...', true)
#14 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OC\\Memcache\\Fac...')
#15 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get('OC\\Memcache\\Fac...')
#16 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#17 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#18 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OCP\\ICacheFacto...')
#19 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramewo                                 rk\Utility\SimpleContainer->query('OCP\\ICacheFacto...', true)
#20 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OCP\\ICacheFacto...')
#21 /usr/local/www/nextcloud/lib/private/Server.php(1130): OC\AppFramework\Utility\SimpleContainer->get('OCP\\ICacheFacto...')
#22 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#23 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#24 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OCP\\Lock\\ILocki...')
#25 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramewo                                 rk\Utility\SimpleContainer->query('OCP\\Lock\\ILocki...', true)
#26 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OCP\\Lock\\ILocki...')
#27 /usr/local/www/nextcloud/lib/private/Server.php(2088): OC\AppFramework\Utility\SimpleContainer->get('OCP\\Lock\\ILocki...')
#28 /usr/local/www/nextcloud/lib/private/Files/View.php(107): OC\Server->getLockingProvider()
#29 /usr/local/www/nextcloud/lib/private/Server.php(470): OC\Files\View->__construct()
#30 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}(Object(OC\Server))
#31 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122                                 ): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#32 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet('OC\\Files\\Node\\H...')
#33 /usr/local/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramewo                                 rk\Utility\SimpleContainer->query('OC\\Files\\Node\\H...', true)
#34 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query('OC\\Files\\Node\\H...')
#35 /usr/local/www/nextcloud/lib/private/Server.php(1490): OC\AppFramework\Utili                                 ty\SimpleContainer->get('OC\\Files\\Node\\H...')
#36 /usr/local/www/nextcloud/lib/base.php(635): OC\Server->boot()
#37 /usr/local/www/nextcloud/lib/base.php(1196): OC::init()
#38 /usr/local/www/nextcloud/cron.php(43): require_once('/usr/local/www/...')
#39 {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 fstab -r nextcloud /mnt/NAS-pool/temp/freenas-iocage-nextcloud/includes/mnt/includes nullfs rw 0 0
Successfully removed mount from nextcloud's fstab
+ echo 'Installation complete!'
Installation complete!
+ [ 0 -eq 1 ]
+ echo 'Using your web browser, go to xxxxxxxx to log in'
Using your web browser, go to xxxxxxxxxxx to log in
+ [ true '==' true ]
+ echo 'You did a reinstall, please use your old database and account credentials'
You did a reinstall, please use your old database and account credentials
+ echo ''

+ [ 0 -eq 1 ]
+ [ 1 -eq 1 ]
+ echo $'You have obtained your Let\'s Encrypt certificate using the staging server.'
You have obtained your Let's Encrypt certificate using the staging server.
+ echo 'This certificate will not be trusted by your browser and will cause SSL errors'
This certificate will not be trusted by your browser and will cause SSL errors
+ echo $'when you connect.  Once you\'ve verified that everything else is working'
when you connect.  Once you've verified that everything else is working
+ echo 'correctly, you should issue a trusted certificate.  To do this, run:'
correctly, you should issue a trusted certificate.  To do this, run:
+ echo '  iocage exec nextcloud /root/remove-staging.sh'
  iocage exec nextcloud /root/remove-staging.sh
+ echo ''
danb35 commented 6 months ago

Fixed by #211