2022-04-04 19:12:07 +02:00
#!/bin/bash
2021-11-30 11:20:42 +01:00
# version_greater A B returns whether A > B
version_greater( ) {
[ " $( printf '%s\n' " $@ " | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1) " != " $1 " ]
}
# return true if specified directory is empty
directory_empty( ) {
[ -z " $( ls -A " $1 / " ) " ]
}
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update( ) {
2024-08-07 13:30:23 +02:00
if php /var/www/html/occ status | grep maintenance | grep -q true; then
php /var/www/html/occ maintenance:mode --off
fi
2023-06-10 09:59:14 +02:00
if php /var/www/html/occ status | grep needsDbUpgrade | grep -q true; then
php /var/www/html/occ upgrade
php /var/www/html/occ app:enable nextcloud-aio --force
fi
}
2025-11-28 13:02:20 +01:00
# Create cert bundle
if env | grep -q NEXTCLOUD_TRUSTED_CERTIFICATES_; then
# Enable debug mode
set -x
# Default vars
CERTIFICATES_ROOT_DIR = "/var/www/html/data/certificates"
CERTIFICATE_BUNDLE = "/var/www/html/data/certificates/ca-bundle.crt"
# Remove old root certs and recreate them with current ones
rm -rf " $CERTIFICATES_ROOT_DIR "
mkdir -p " $CERTIFICATES_ROOT_DIR "
# Retrieve default root cert bundle
if ! [ -f " $SOURCE_LOCATION /resources/config/ca-bundle.crt " ] ; then
echo "Root ca-bundle not found. Only concattening configured NEXTCLOUD_TRUSTED_CERTIFICATES files!"
# Recreate cert file
touch " $CERTIFICATE_BUNDLE "
else
# Write default bundle to the target ca file
cat " $SOURCE_LOCATION /resources/config/ca-bundle.crt " > " $CERTIFICATE_BUNDLE "
fi
# Iterate through certs
TRUSTED_CERTIFICATES = " $( env | grep NEXTCLOUD_TRUSTED_CERTIFICATES_ | grep -oP '^[A-Z_a-z0-9]+' ) "
mapfile -t TRUSTED_CERTIFICATES <<< " $TRUSTED_CERTIFICATES "
for certificate in " ${ TRUSTED_CERTIFICATES [@] } " ; do
# Create new line
echo "" >> " $CERTIFICATE_BUNDLE "
# Check if variable is an actual cert
if echo " ${ !certificate } " | grep -q "BEGIN CERTIFICATE" && echo " ${ !certificate } " | grep -q "END CERTIFICATE" ; then
# Write out cert to bundle
echo " ${ !certificate } " >> " $CERTIFICATE_BUNDLE "
fi
# Create file in cert dir for extra logic in other places
if ! [ -f " $CERTIFICATES_ROOT_DIR / $CERTIFICATE_NAME " ] ; then
touch " $CERTIFICATES_ROOT_DIR / $CERTIFICATE_NAME "
fi
done
# Custom logic for ldap conf
if ! grep -q "TLS_" /etc/openldap/ldap.conf; then
cat << EOL >> /etc/openldap/ldap.conf
TLS_CACERT $CERTIFICATE_BUNDLE
TLS_REQCERT try
EOL
fi
# Backwards compatibility with older instances
if [ -f "/var/www/html/config/postgres.config.php" ] ; then
sed -i "s|/var/www/html/data/certificates/POSTGRES|/var/www/html/data/certificates/ca-bundle.crt|" /var/www/html/config/postgres.config.php
sed -i "s|/var/www/html/data/certificates/MYSQL|/var/www/html/data/certificates/ca-bundle.crt|" /var/www/html/config/postgres.config.php
fi
# Print out bundle one last time
cat " $CERTIFICATE_BUNDLE "
# Disable debug mode
set +x
fi
2024-10-18 17:50:31 +02:00
# Adjust DATABASE_TYPE to by Nextcloud supported value
if [ " $DATABASE_TYPE " = postgres ] ; then
export DATABASE_TYPE = pgsql
fi
2025-09-26 15:27:56 -04:00
# Only start container if Redis is accessible
2024-05-29 13:48:00 +02:00
# shellcheck disable=SC2153
2025-12-08 15:36:02 +01:00
while ! nc -z " $REDIS_HOST " " $REDIS_PORT " ; do
2025-09-26 15:27:56 -04:00
echo "Waiting for Redis to start..."
2024-05-29 13:48:00 +02:00
sleep 5
done
2022-03-08 16:49:13 +01:00
# Check permissions in ncdata
2025-09-26 15:27:56 -04:00
test_file = " $NEXTCLOUD_DATA_DIR /this-is-a-test-file "
touch " $test_file "
if ! [ -f " $test_file " ] ; then
echo "The www-data user does not appear to have access rights to the data directory."
echo "It is possible that the files are on a filesystem that does not support standard Linux permissions,"
echo "or the permissions simply need to be adjusted. Please change the permissions as described below."
echo "Current permissions are:"
stat -c "%u:%g %a" " $NEXTCLOUD_DATA_DIR "
echo "(userID:groupID permissions)"
echo "They should be:"
echo "33:0 750"
echo "(userID:groupID permissions)"
echo "Also, ensure that all parent directories on the host of your chosen data directory are publicly readable."
echo "For example: sudo chmod +r /mnt (adjust this command as needed)."
echo "If you want to use a FUSE mount as the data directory, add 'allow_other' as an additional mount option."
echo "For SMB/CIFS mounts as the data directory, see:"
echo " https://github.com/nextcloud/all-in-one#can-i-use-a-cifssmb-share-as-nextclouds-datadir"
2022-03-08 16:49:13 +01:00
exit 1
fi
2025-09-26 15:27:56 -04:00
rm -f " $test_file "
2022-03-08 16:49:13 +01:00
2021-11-30 11:20:42 +01:00
if [ -f /var/www/html/version.php ] ; then
# shellcheck disable=SC2016
installed_version = " $( php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);' ) "
else
installed_version = "0.0.0.0"
fi
2024-02-28 21:57:25 +01:00
if [ -f " $SOURCE_LOCATION /version.php " ] ; then
2021-11-30 11:20:42 +01:00
# shellcheck disable=SC2016
2024-02-28 21:57:25 +01:00
image_version = " $( php -r " require ' $SOURCE_LOCATION /version.php'; echo implode('.', \$OC_Version); " ) "
2021-11-30 11:20:42 +01:00
else
image_version = " $installed_version "
fi
# unset admin password
if [ " $installed_version " != "0.0.0.0" ] ; then
unset ADMIN_PASSWORD
fi
2022-04-26 19:17:38 +02:00
# Don't start the container if Nextcloud is not compatible with the PHP version
if [ -f "/var/www/html/lib/versioncheck.php" ] && ! php /var/www/html/lib/versioncheck.php; then
2025-09-26 15:27:56 -04:00
echo "Your installed Nextcloud version is not compatible with the PHP version provided by this image."
echo "This typically occurs when you restore an older Nextcloud backup that does not support the"
echo "PHP version included in this image."
echo "Please restore a more recent backup that includes a compatible Nextcloud version."
echo "If you do not have a more recent backup, refer to the manual upgrade documentation:"
echo " https://github.com/nextcloud/all-in-one/blob/main/manual-upgrade.md"
2022-04-26 19:17:38 +02:00
exit 1
fi
2022-08-15 14:00:48 +02:00
# Do not start the container if the last update failed
2022-09-20 16:33:43 +02:00
if [ -f " $NEXTCLOUD_DATA_DIR /update.failed " ] ; then
2022-08-15 14:00:48 +02:00
echo "The last Nextcloud update failed."
2025-09-26 15:27:56 -04:00
echo "Please restore from a backup and try again."
echo "If you do not have a backup, you can delete the update.failed file in the data directory"
echo "to allow the container to start again."
2022-08-15 14:00:48 +02:00
exit 1
fi
2022-12-16 10:57:42 +01:00
# Do not start the container if the install failed
if [ -f " $NEXTCLOUD_DATA_DIR /install.failed " ] ; then
echo "The initial Nextcloud installation failed."
2025-09-26 15:27:56 -04:00
echo "For more information about what went wrong, check the logs above."
echo "Please reset AIO properly and try again."
echo "See:"
echo " https://github.com/nextcloud/all-in-one#how-to-properly-reset-the-instance"
2022-12-16 10:57:42 +01:00
exit 1
fi
2021-12-07 18:45:52 +01:00
# Skip any update if Nextcloud was just restored
2022-09-20 16:33:43 +02:00
if ! [ -f " $NEXTCLOUD_DATA_DIR /skip.update " ] ; then
2021-12-07 18:45:52 +01:00
if version_greater " $image_version " " $installed_version " ; then
# Check if it skips a major version
INSTALLED_MAJOR = " ${ installed_version %%.* } "
2021-11-30 11:20:42 +01:00
IMAGE_MAJOR = " ${ image_version %%.* } "
2022-11-17 17:54:09 +01:00
if [ " $installed_version " != "0.0.0.0" ] ; then
# Write output to logfile.
exec > >( tee -i "/var/www/html/data/update.log" )
exec 2>& 1
fi
2021-12-07 18:45:52 +01:00
if [ " $installed_version " != "0.0.0.0" ] && [ " $(( IMAGE_MAJOR - INSTALLED_MAJOR)) " -gt 1 ] ; then
2024-02-28 19:08:00 +01:00
# Do not skip major versions placeholder # Do not remove or change this line!
# Do not skip major versions start # Do not remove or change this line!
2021-12-07 18:45:52 +01:00
set -ex
NEXT_MAJOR = " $(( INSTALLED_MAJOR + 1 )) "
curl -fsSL -o nextcloud.tar.bz2 " https://download.nextcloud.com/server/releases/latest- ${ NEXT_MAJOR } .tar.bz2 "
curl -fsSL -o nextcloud.tar.bz2.asc " https://download.nextcloud.com/server/releases/latest- ${ NEXT_MAJOR } .tar.bz2.asc "
2022-02-11 11:37:05 +01:00
GNUPGHOME = " $( mktemp -d) "
export GNUPGHOME
2021-12-07 18:45:52 +01:00
# gpg key from https://nextcloud.com/nextcloud.asc
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 28806A878AE423A28372792ED75899B9A724937A
gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2
mkdir -p /usr/src/tmp
tar -xjf nextcloud.tar.bz2 -C /usr/src/tmp/
gpgconf --kill all
rm nextcloud.tar.bz2.asc nextcloud.tar.bz2
mkdir -p /usr/src/tmp/nextcloud/data
mkdir -p /usr/src/tmp/nextcloud/custom_apps
chmod +x /usr/src/tmp/nextcloud/occ
2024-02-28 21:57:25 +01:00
cp -r " $SOURCE_LOCATION " /config/* /usr/src/tmp/nextcloud/config/
2022-05-02 17:01:04 +02:00
mkdir -p /usr/src/tmp/nextcloud/apps/nextcloud-aio
2024-02-28 21:57:25 +01:00
cp -r " $SOURCE_LOCATION " /apps/nextcloud-aio/* /usr/src/tmp/nextcloud/apps/nextcloud-aio/
mv " $SOURCE_LOCATION " /usr/src/temp-nextcloud
mv /usr/src/tmp/nextcloud " $SOURCE_LOCATION "
2021-12-07 18:45:52 +01:00
rm -r /usr/src/tmp
rm -r /usr/src/temp-nextcloud
# shellcheck disable=SC2016
2024-12-06 11:37:05 +01:00
image_version = " $( php -r " require ' $SOURCE_LOCATION /version.php'; echo implode('.', \$OC_Version); " ) "
2021-12-07 18:45:52 +01:00
IMAGE_MAJOR = " ${ image_version %%.* } "
set +ex
2024-02-28 19:08:00 +01:00
# Do not skip major versions end # Do not remove or change this line!
2021-12-07 18:45:52 +01:00
fi
2021-11-30 11:20:42 +01:00
2021-12-07 18:45:52 +01:00
if [ " $installed_version " != "0.0.0.0" ] ; then
2024-12-09 12:10:32 +01:00
# Check connection to appstore start # Do not remove or change this line!
2021-12-07 18:45:52 +01:00
while true; do
2025-09-26 15:27:56 -04:00
echo -e "Checking connection to the app store..."
2025-06-11 15:33:41 +02:00
APPSTORE_URL = "https://apps.nextcloud.com/api/v1"
2025-01-06 11:56:45 +01:00
if grep -q appstoreurl /var/www/html/config/config.php; then
set -x
APPSTORE_URL = " $( grep appstoreurl /var/www/html/config/config.php | grep -oP 'https://.*v[0-9]+' ) "
set +x
fi
2025-06-02 15:55:13 +08:00
# Default appstoreurl parameter in config.php defaults to 'https://apps.nextcloud.com/api/v1' so we check for the apps.json file stored in there
2025-06-02 04:06:37 +08:00
CURL_STATUS = " $( curl -LI " $APPSTORE_URL " /apps.json -o /dev/null -w '%{http_code}\n' -s) "
2021-12-07 18:45:52 +01:00
if [ [ " $CURL_STATUS " = "200" ] ]
then
2025-09-26 15:27:56 -04:00
echo "App store is reachable."
2021-12-07 18:45:52 +01:00
break
else
2025-09-26 15:27:56 -04:00
echo "Curl did not return a 200 status. Is the app store reachable?"
2022-01-21 14:02:35 +01:00
sleep 5
2021-12-07 18:45:52 +01:00
fi
done
2024-12-09 12:10:32 +01:00
# Check connection to appstore end # Do not remove or change this line!
2021-12-07 18:45:52 +01:00
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2021-12-07 18:45:52 +01:00
php /var/www/html/occ maintenance:mode --off
2025-09-26 15:27:56 -04:00
echo "Getting and backing up the status of apps for later; this might take a while..."
2022-11-17 17:54:09 +01:00
NC_APPS = " $( find /var/www/html/custom_apps/ -type d -maxdepth 1 -mindepth 1 | sed 's|/var/www/html/custom_apps/||g' ) "
if [ -z " $NC_APPS " ] ; then
2025-09-26 15:27:56 -04:00
echo "No apps detected. Aborting export of app status..."
2022-11-17 17:54:09 +01:00
APPSTORAGE = "no-export-done"
else
2022-11-21 18:38:34 +01:00
mapfile -t NC_APPS_ARRAY <<< " $NC_APPS "
2022-11-17 17:54:09 +01:00
declare -Ag APPSTORAGE
2025-09-26 15:27:56 -04:00
echo "Disabling apps before the update to make the update procedure safer. This can take a while..."
2022-11-17 17:54:09 +01:00
for app in " ${ NC_APPS_ARRAY [@] } " ; do
2024-06-11 10:38:38 +02:00
if APPSTORAGE[ $app ] = " $( php /var/www/html/occ config:app:get " $app " enabled) " ; then
2024-06-10 10:24:30 +02:00
php /var/www/html/occ app:disable " $app "
else
APPSTORAGE[ $app ] = ""
2025-09-26 15:27:56 -04:00
echo " Not disabling $app because the occ command to get its enabled state failed. "
2024-06-10 10:24:30 +02:00
fi
2022-11-17 17:54:09 +01:00
done
fi
2021-12-07 18:45:52 +01:00
if [ " $(( IMAGE_MAJOR - INSTALLED_MAJOR)) " -eq 1 ] ; then
php /var/www/html/occ config:system:delete app_install_overwrite
2021-11-30 11:20:42 +01:00
fi
2021-12-07 18:45:52 +01:00
php /var/www/html/occ app:update --all
2022-01-29 22:29:15 +01:00
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2021-11-30 11:20:42 +01:00
fi
2025-09-26 15:27:56 -04:00
echo " Initializing Nextcloud $image_version ... "
# Copy over initial data from Nextcloud archive
rsync -rlD --delete \
--exclude-from= /upgrade.exclude \
" $SOURCE_LOCATION / " \
/var/www/html/
2021-11-30 11:20:42 +01:00
2025-09-11 16:18:32 +02:00
# Copy custom_apps from Nextcloud archive
if ! directory_empty " $SOURCE_LOCATION /custom_apps " ; then
set -x
for app in " $SOURCE_LOCATION /custom_apps " /*; do
app_id = " $( basename " $app " ) "
mkdir -p " /var/www/html/custom_apps/ $app_id "
2025-09-26 15:27:56 -04:00
rsync -rlD --delete \
--include " / $app_id / " \
--exclude '/*' \
" $SOURCE_LOCATION /custom_apps/ " \
/var/www/html/custom_apps/
2025-09-11 16:18:32 +02:00
done
set +x
fi
2025-09-26 15:27:56 -04:00
# Copy these from Nextcloud archive if they don't exist yet (i.e. new install)
2025-09-12 12:48:45 +02:00
for dir in config data custom_apps themes; do
2021-12-07 18:45:52 +01:00
if [ ! -d " /var/www/html/ $dir " ] || directory_empty " /var/www/html/ $dir " ; then
2025-09-26 15:27:56 -04:00
rsync -rlD \
--include " / $dir / " \
--exclude '/*' \
" $SOURCE_LOCATION / " \
/var/www/html/
2021-12-07 18:45:52 +01:00
fi
done
2025-09-26 15:27:56 -04:00
rsync -rlD --delete \
--include '/config/' \
--exclude '/*' \
--exclude '/config/CAN_INSTALL' \
--exclude '/config/config.sample.php' \
--exclude '/config/config.php' \
" $SOURCE_LOCATION / " \
/var/www/html/
rsync -rlD \
--include '/version.php' \
--exclude '/*' \
" $SOURCE_LOCATION / " \
/var/www/html/
2021-12-07 18:45:52 +01:00
echo "Initializing finished"
2021-11-30 11:20:42 +01:00
2025-09-26 15:27:56 -04:00
################
# Fresh Install
################
2021-12-07 18:45:52 +01:00
if [ " $installed_version " = "0.0.0.0" ] ; then
2023-02-06 18:07:57 +01:00
echo "New Nextcloud instance."
# Write output to logfile.
mkdir -p /var/www/html/data
exec > >( tee -i "/var/www/html/data/install.log" )
exec 2>& 1
2021-11-30 11:20:42 +01:00
2021-12-07 18:45:52 +01:00
INSTALL_OPTIONS = ( -n --admin-user " $ADMIN_USER " --admin-pass " $ADMIN_PASSWORD " )
if [ -n " ${ NEXTCLOUD_DATA_DIR } " ] ; then
INSTALL_OPTIONS += ( --data-dir " $NEXTCLOUD_DATA_DIR " )
fi
2021-11-30 11:20:42 +01:00
2025-09-26 15:27:56 -04:00
# Skip the default permission check (we do our own)
cat > /var/www/html/config/datadir.permission.config.php <<'EOF'
2023-05-21 00:49:49 +02:00
<?php
2025-09-26 15:27:56 -04:00
$CONFIG = array (
'check_data_directory_permissions' = > false
) ;
EOF
2023-05-21 00:49:49 +02:00
2024-10-18 17:50:31 +02:00
echo " Installing with $DATABASE_TYPE database "
2023-10-02 20:27:47 +02:00
# Set a default value for POSTGRES_PORT
if [ -z " $POSTGRES_PORT " ] ; then
2025-09-26 15:27:56 -04:00
POSTGRES_PORT = 5432
2023-10-02 20:27:47 +02:00
fi
2021-12-07 18:45:52 +01:00
2025-09-26 15:27:56 -04:00
# Add database options to INSTALL_OPTIONS
# shellcheck disable=SC2153
INSTALL_OPTIONS += (
--database " $DATABASE_TYPE "
--database-name " $POSTGRES_DB "
--database-user " $POSTGRES_USER "
--database-pass " $POSTGRES_PASSWORD "
--database-host " $POSTGRES_HOST "
--database-port " $POSTGRES_PORT "
)
2023-02-02 19:41:41 +01:00
echo "Starting Nextcloud installation..."
2023-02-06 18:07:57 +01:00
if ! php /var/www/html/occ maintenance:install " ${ INSTALL_OPTIONS [@] } " ; then
echo "Installation of Nextcloud failed!"
touch " $NEXTCLOUD_DATA_DIR /install.failed "
exit 1
fi
2023-02-06 18:32:14 +01:00
# Try to force generation of appdata dir:
php /var/www/html/occ maintenance:repair
2023-02-23 17:09:10 +01:00
if [ -z " $OBJECTSTORE_S3_BUCKET " ] && [ -z " $OBJECTSTORE_SWIFT_URL " ] ; then
max_retries = 10
try = 0
while [ -z " $( find " $NEXTCLOUD_DATA_DIR / " -maxdepth 1 -mindepth 1 -type d -name "appdata_*" ) " ] && [ " $try " -lt " $max_retries " ] ; do
echo "Waiting for appdata to become available..."
try = $(( try+1))
sleep 10s
done
2023-02-06 18:18:52 +01:00
2023-02-23 17:09:10 +01:00
if [ " $try " -ge " $max_retries " ] ; then
echo "Installation of Nextcloud failed!"
2025-09-26 15:27:56 -04:00
echo " Installation errors: $( cat /var/www/html/data/nextcloud.log) "
2023-02-23 17:09:10 +01:00
touch " $NEXTCLOUD_DATA_DIR /install.failed "
exit 1
fi
2021-12-07 18:45:52 +01:00
fi
2021-11-30 11:20:42 +01:00
2023-03-30 10:54:56 +02:00
# This autoconfig is not needed anymore and should be able to be overwritten by the user
rm /var/www/html/config/datadir.permission.config.php
2021-12-07 18:45:52 +01:00
# unset admin password
unset ADMIN_PASSWORD
2025-06-10 10:12:34 +02:00
# Enable the updatenotification app but disable its UI and server update notifications
php /var/www/html/occ config:system:set updatechecker --type= bool --value= false
php /var/www/html/occ config:app:set updatenotification notify_groups --value= "[]"
2024-02-28 19:08:00 +01:00
# AIO update to latest start # Do not remove or change this line!
2023-03-29 17:39:31 +02:00
if [ " $INSTALL_LATEST_MAJOR " = yes ] ; then
2023-04-02 11:26:42 +02:00
php /var/www/html/occ config:system:set updatedirectory --value= "/nc-updater"
2023-12-12 14:16:03 +01:00
INSTALLED_AT = " $( php /var/www/html/occ config:app:get core installedat) "
if [ -n " ${ INSTALLED_AT } " ] ; then
2023-12-11 10:43:47 +01:00
# Set the installdat to 00 which will allow to skip staging and install the next major directly
# shellcheck disable=SC2001
2023-12-12 14:16:03 +01:00
INSTALLED_AT = " $( echo " ${ INSTALLED_AT } " | sed " s|[0-9][0-9] $|00| " ) "
php /var/www/html/occ config:app:set core installedat --value= " ${ INSTALLED_AT } "
2023-12-11 10:43:47 +01:00
fi
php /var/www/html/updater/updater.phar --no-interaction --no-backup
2023-03-29 17:39:31 +02:00
if ! php /var/www/html/occ -V || php /var/www/html/occ status | grep maintenance | grep -q 'true' ; then
echo "Installation of Nextcloud failed!"
touch " $NEXTCLOUD_DATA_DIR /install.failed "
2023-04-02 11:26:42 +02:00
exit 1
2023-03-29 17:39:31 +02:00
fi
2023-04-15 12:52:25 +02:00
# shellcheck disable=SC2016
installed_version = " $( php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);' ) "
2023-12-12 16:37:29 +01:00
INSTALLED_MAJOR = " ${ installed_version %%.* } "
IMAGE_MAJOR = " ${ image_version %%.* } "
2025-09-26 15:27:56 -04:00
# If a valid upgrade path, trigger the Nextcloud built-in Updater
2023-12-12 16:37:29 +01:00
if ! [ " $INSTALLED_MAJOR " -gt " $IMAGE_MAJOR " ] ; then
php /var/www/html/updater/updater.phar --no-interaction --no-backup
if ! php /var/www/html/occ -V || php /var/www/html/occ status | grep maintenance | grep -q 'true' ; then
echo "Installation of Nextcloud failed!"
2025-09-26 15:27:56 -04:00
# TODO: Add a hint here about what to do / where to look / updater.log?
2023-12-12 16:37:29 +01:00
touch " $NEXTCLOUD_DATA_DIR /install.failed "
exit 1
fi
# shellcheck disable=SC2016
installed_version = " $( php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);' ) "
fi
2025-06-10 10:12:34 +02:00
php /var/www/html/occ config:system:set updatechecker --type= bool --value= true
2023-06-02 14:18:50 +02:00
php /var/www/html/occ app:enable nextcloud-aio --force
2023-03-29 17:39:31 +02:00
php /var/www/html/occ db:add-missing-columns
php /var/www/html/occ db:add-missing-primary-keys
yes | php /var/www/html/occ db:convert-filecache-bigint
fi
2024-02-28 19:08:00 +01:00
# AIO update to latest end # Do not remove or change this line!
2023-03-29 17:39:31 +02:00
2021-12-07 18:45:52 +01:00
# Apply log settings
echo "Applying default settings..."
mkdir -p /var/www/html/data
2024-05-03 08:27:33 -07:00
php /var/www/html/occ config:system:set loglevel --value= "2" --type= integer
php /var/www/html/occ config:system:set log_type --value= "file"
2022-05-25 15:15:52 +02:00
php /var/www/html/occ config:system:set logfile --value= "/var/www/html/data/nextcloud.log"
2024-05-03 08:27:33 -07:00
php /var/www/html/occ config:system:set log_rotate_size --value= "10485760" --type= integer
2021-12-07 18:45:52 +01:00
php /var/www/html/occ app:enable admin_audit
2022-05-25 15:15:52 +02:00
php /var/www/html/occ config:app:set admin_audit logfile --value= "/var/www/html/data/audit.log"
2021-12-07 18:45:52 +01:00
php /var/www/html/occ config:system:set log.condition apps 0 --value= "admin_audit"
# Apply preview settings
echo "Applying preview settings..."
2024-05-03 08:27:33 -07:00
php /var/www/html/occ config:system:set preview_max_x --value= "2048" --type= integer
php /var/www/html/occ config:system:set preview_max_y --value= "2048" --type= integer
php /var/www/html/occ config:system:set jpeg_quality --value= "60" --type= integer
2021-12-07 18:45:52 +01:00
php /var/www/html/occ config:app:set preview jpeg_quality --value= "60"
php /var/www/html/occ config:system:delete enabledPreviewProviders
php /var/www/html/occ config:system:set enabledPreviewProviders 1 --value= "OC\\Preview\\Image"
php /var/www/html/occ config:system:set enabledPreviewProviders 2 --value= "OC\\Preview\\MarkDown"
php /var/www/html/occ config:system:set enabledPreviewProviders 3 --value= "OC\\Preview\\MP3"
php /var/www/html/occ config:system:set enabledPreviewProviders 4 --value= "OC\\Preview\\TXT"
php /var/www/html/occ config:system:set enabledPreviewProviders 5 --value= "OC\\Preview\\OpenDocument"
php /var/www/html/occ config:system:set enabledPreviewProviders 6 --value= "OC\\Preview\\Movie"
2023-04-27 15:12:16 +02:00
php /var/www/html/occ config:system:set enabledPreviewProviders 7 --value= "OC\\Preview\\Krita"
2021-12-07 18:45:52 +01:00
php /var/www/html/occ config:system:set enable_previews --value= true --type= boolean
# Apply other settings
echo "Applying other settings..."
2024-03-08 11:47:05 +01:00
# Add missing indices after new installation because they seem to be missing on new installation
php /var/www/html/occ db:add-missing-indices
2021-12-07 18:45:52 +01:00
php /var/www/html/occ config:system:set upgrade.disable-web --type= bool --value= true
php /var/www/html/occ config:system:set mail_smtpmode --value= "smtp"
php /var/www/html/occ config:system:set trashbin_retention_obligation --value= "auto, 30"
php /var/www/html/occ config:system:set versions_retention_obligation --value= "auto, 30"
2024-05-03 08:27:33 -07:00
php /var/www/html/occ config:system:set activity_expire_days --value= "30" --type= integer
2021-12-07 18:45:52 +01:00
php /var/www/html/occ config:system:set simpleSignUpLink.shown --type= bool --value= false
php /var/www/html/occ config:system:set share_folder --value= "/Shared"
2022-02-03 10:28:33 +01:00
# Install some apps by default
2022-09-26 20:27:35 +02:00
if [ -n " $STARTUP_APPS " ] ; then
read -ra STARTUP_APPS_ARRAY <<< " $STARTUP_APPS "
for app in " ${ STARTUP_APPS_ARRAY [@] } " ; do
2023-01-02 16:08:02 +01:00
if ! echo " $app " | grep -q '^-' ; then
2025-09-11 16:18:32 +02:00
if [ -z " $( find /var/www/html/apps /var/www/html/custom_apps -type d -maxdepth 1 -mindepth 1 -name " $app " ) " ] ; then
2023-01-02 16:08:02 +01:00
# If not shipped, install and enable the app
php /var/www/html/occ app:install " $app "
else
# If shipped, enable the app
php /var/www/html/occ app:enable " $app "
fi
else
app = " ${ app #- } "
# Disable the app if '-' was provided in front of the appid
php /var/www/html/occ app:disable " $app "
fi
2022-09-26 20:27:35 +02:00
done
fi
2022-02-03 10:28:33 +01:00
2021-12-07 18:45:52 +01:00
#upgrade
else
2022-11-21 18:38:34 +01:00
touch " $NEXTCLOUD_DATA_DIR /update.failed "
2025-09-26 15:27:56 -04:00
echo " Upgrading Nextcloud from $installed_version to $image_version ... "
2023-06-10 14:49:50 +02:00
php /var/www/html/occ config:system:delete integrity.check.disabled
2021-12-07 18:45:52 +01:00
if ! php /var/www/html/occ upgrade || ! php /var/www/html/occ -V; then
echo "Upgrade failed. Please restore from backup."
2025-09-26 15:27:56 -04:00
bash /notify.sh " Nextcloud update to $image_version failed! " "Please restore from backup."
2021-12-07 18:45:52 +01:00
exit 1
fi
2021-11-30 11:20:42 +01:00
2023-10-05 15:59:36 +02:00
# shellcheck disable=SC2016
installed_version = " $( php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);' ) "
2022-09-20 16:33:43 +02:00
rm " $NEXTCLOUD_DATA_DIR /update.failed "
2025-09-26 15:27:56 -04:00
bash /notify.sh " Nextcloud update to $image_version successful! " "You may inspect the Nextcloud container logs for more information."
2022-04-20 17:16:43 +02:00
2022-11-17 18:05:23 +01:00
php /var/www/html/occ app:update --all
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2022-11-17 17:54:09 +01:00
# Restore app status
if [ " ${ APPSTORAGE [0] } " != "no-export-done" ] ; then
2025-09-26 15:27:56 -04:00
echo "Restoring app statuses. This may take a while..."
2022-11-17 17:54:09 +01:00
for app in " ${ !APPSTORAGE[@] } " ; do
if [ -n " ${ APPSTORAGE [ $app ] } " ] ; then
if [ " ${ APPSTORAGE [ $app ] } " != "no" ] ; then
echo " Enabling $app ... "
if ! php /var/www/html/occ app:enable " $app " >/dev/null; then
2023-06-03 14:00:40 +02:00
php /var/www/html/occ app:disable " $app " >/dev/null
2023-06-06 09:44:11 +02:00
if ! php /var/www/html/occ -V & >/dev/null; then
rm -r " /var/www/html/custom_apps/ $app "
php /var/www/html/occ maintenance:mode --off
fi
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2025-09-26 15:27:56 -04:00
echo " The $app app could not be re-enabled, probably because it is not compatible with the new Nextcloud version. "
2022-11-21 16:44:51 +01:00
if [ " $app " = apporder ] ; then
CUSTOM_HINT = "The apporder app was deprecated. A possible replacement is the side_menu app, aka 'Custom menu'."
else
2025-09-26 15:27:56 -04:00
CUSTOM_HINT = "Most likely, it is not compatible with the new Nextcloud version."
2022-11-21 16:44:51 +01:00
fi
2025-09-26 15:27:56 -04:00
bash /notify.sh " Could not re-enable the $app app after the Nextcloud update! " " $CUSTOM_HINT Feel free to review the Nextcloud update logs and force-enable the app again if you wish. "
2022-11-17 17:54:09 +01:00
continue
fi
# Only restore the group settings, if the app was enabled (and is thus compatible with the new NC version)
if [ " ${ APPSTORAGE [ $app ] } " != "yes" ] ; then
2022-11-17 18:05:23 +01:00
php /var/www/html/occ config:app:set " $app " enabled --value= " ${ APPSTORAGE [ $app ] } "
2022-11-17 17:54:09 +01:00
fi
fi
fi
done
fi
2021-12-07 18:45:52 +01:00
2022-11-17 18:05:23 +01:00
php /var/www/html/occ app:update --all
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2025-06-10 10:12:34 +02:00
# Enable the updatenotification app but disable its UI and server update notifications
php /var/www/html/occ config:system:set updatechecker --type= bool --value= false
php /var/www/html/occ app:enable updatenotification
php /var/www/html/occ config:app:set updatenotification notify_groups --value= "[]"
2021-12-07 18:45:52 +01:00
# Apply optimization
2025-09-26 15:27:56 -04:00
echo "Performing some optimizations..."
2024-07-26 13:51:47 +02:00
if [ " $NEXTCLOUD_SKIP_DATABASE_OPTIMIZATION " != yes ] ; then
2024-09-04 16:23:18 +02:00
php /var/www/html/occ maintenance:repair --include-expensive
2024-07-26 13:51:47 +02:00
php /var/www/html/occ db:add-missing-indices
php /var/www/html/occ db:add-missing-columns
php /var/www/html/occ db:add-missing-primary-keys
yes | php /var/www/html/occ db:convert-filecache-bigint
2024-09-04 16:23:18 +02:00
else
php /var/www/html/occ maintenance:repair
2024-07-26 13:51:47 +02:00
fi
2021-11-30 11:20:42 +01:00
fi
fi
2022-04-04 19:12:07 +02:00
2022-07-08 11:24:03 +02:00
# Performing update of all apps if daily backups are enabled, running and successful and if it is saturday
2022-07-10 21:47:25 +02:00
if [ " $UPDATE_NEXTCLOUD_APPS " = 'yes' ] && [ " $( date +%u) " = 6 ] ; then
2022-04-20 17:16:43 +02:00
UPDATED_APPS = " $( php /var/www/html/occ app:update --all) "
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2022-04-20 17:16:43 +02:00
if [ -n " $UPDATED_APPS " ] ; then
bash /notify.sh "Your apps just got updated!" " $UPDATED_APPS "
fi
2022-04-04 19:12:07 +02:00
fi
2022-10-27 13:50:26 +02:00
else
SKIP_UPDATE = 1
2021-11-30 11:20:42 +01:00
fi
2023-06-10 09:59:14 +02:00
run_upgrade_if_needed_due_to_app_update
2022-08-22 11:14:19 +02:00
if [ -z " $OBJECTSTORE_S3_BUCKET " ] && [ -z " $OBJECTSTORE_SWIFT_URL " ] ; then
2023-02-23 17:09:10 +01:00
# Check if appdata is present
# If not, something broke (e.g. changing ncdatadir after aio was first started)
if [ -z " $( find " $NEXTCLOUD_DATA_DIR / " -maxdepth 1 -mindepth 1 -type d -name "appdata_*" ) " ] ; then
2025-09-26 15:27:56 -04:00
echo "Appdata is not present. Did you change the datadir after the initial Nextcloud installation? This is not supported!"
2023-02-23 17:09:10 +01:00
echo "See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir"
2025-09-26 15:27:56 -04:00
echo "If you moved the datadir to an external drive, make sure that the drive is still mounted."
echo "The following was found in the datadir:"
2023-02-23 17:09:10 +01:00
ls -la " $NEXTCLOUD_DATA_DIR / "
exit 1
fi
2023-06-26 15:14:33 +02:00
# Delete formerly configured tempdirectory as the default is usually faster (if the datadir is on a HDD or network FS)
if [ " $( php /var/www/html/occ config:system:get tempdirectory) " = " $NEXTCLOUD_DATA_DIR /tmp/ " ] ; then
php /var/www/html/occ config:system:delete tempdirectory
if [ -d " $NEXTCLOUD_DATA_DIR /tmp/ " ] ; then
rm -r " $NEXTCLOUD_DATA_DIR /tmp/ "
fi
2022-08-22 11:14:19 +02:00
fi
2023-06-26 15:14:33 +02:00
2022-08-22 11:14:19 +02:00
fi
2022-04-26 15:44:13 +02:00
# Perform fingerprint update if instance was restored
2022-09-20 16:33:43 +02:00
if [ -f " $NEXTCLOUD_DATA_DIR /fingerprint.update " ] ; then
2022-04-26 15:44:13 +02:00
php /var/www/html/occ maintenance:data-fingerprint
2022-09-20 16:33:43 +02:00
rm " $NEXTCLOUD_DATA_DIR /fingerprint.update "
2022-04-26 15:44:13 +02:00
fi
2024-11-08 11:10:01 +01:00
# Perform preview scan if previews were excluded from restore
if [ -f " $NEXTCLOUD_DATA_DIR /trigger-preview.scan " ] ; then
php /var/www/html/occ files:scan-app-data preview -vvv
rm " $NEXTCLOUD_DATA_DIR /trigger-preview.scan "
fi
2024-02-28 19:08:00 +01:00
# AIO one-click settings start # Do not remove or change this line!
2021-11-30 11:20:42 +01:00
# Apply one-click-instance settings
echo "Applying one-click-instance settings..."
php /var/www/html/occ config:system:set one-click-instance --value= true --type= bool
php /var/www/html/occ config:system:set one-click-instance.user-limit --value= 100 --type= int
2022-10-25 18:13:16 +02:00
php /var/www/html/occ config:system:set one-click-instance.link --value= "https://nextcloud.com/all-in-one/"
2024-02-28 19:08:00 +01:00
# AIO one-click settings end # Do not remove or change this line!
2022-10-25 18:13:16 +02:00
php /var/www/html/occ app:enable support
2023-11-16 13:58:06 +01:00
if [ -n " $SUBSCRIPTION_KEY " ] && [ -z " $( php /var/www/html/occ config:app:get support potential_subscription_key) " ] ; then
php /var/www/html/occ config:app:set support potential_subscription_key --value= " $SUBSCRIPTION_KEY "
php /var/www/html/occ config:app:delete support last_check
fi
2024-05-28 11:15:13 +02:00
if [ -n " $NEXTCLOUD_DEFAULT_QUOTA " ] ; then
if [ " $NEXTCLOUD_DEFAULT_QUOTA " = "unlimited" ] ; then
php /var/www/html/occ config:app:delete files default_quota
else
php /var/www/html/occ config:app:set files default_quota --value= " $NEXTCLOUD_DEFAULT_QUOTA "
fi
fi
2021-11-30 11:20:42 +01:00
2022-05-25 15:15:52 +02:00
# Adjusting log files to be stored on a volume
echo "Adjusting log files..."
2023-06-10 09:59:14 +02:00
php /var/www/html/occ config:system:set upgrade.cli-upgrade-link --value= "https://github.com/nextcloud/all-in-one/discussions/2726"
2022-05-25 15:15:52 +02:00
php /var/www/html/occ config:system:set logfile --value= "/var/www/html/data/nextcloud.log"
php /var/www/html/occ config:app:set admin_audit logfile --value= "/var/www/html/data/audit.log"
2023-04-02 11:26:42 +02:00
php /var/www/html/occ config:system:set updatedirectory --value= "/nc-updater"
2025-03-20 16:36:21 +01:00
if [ -n " $NEXTCLOUD_SKELETON_DIRECTORY " ] ; then
if [ " $NEXTCLOUD_SKELETON_DIRECTORY " = "empty" ] ; then
php /var/www/html/occ config:system:set skeletondirectory --value= ""
else
php /var/www/html/occ config:system:set skeletondirectory --value= " $NEXTCLOUD_SKELETON_DIRECTORY "
fi
fi
2023-12-07 12:32:08 +01:00
if [ -n " $SERVERINFO_TOKEN " ] && [ -z " $( php /var/www/html/occ config:app:get serverinfo token) " ] ; then
php /var/www/html/occ config:app:set serverinfo token --value= " $SERVERINFO_TOKEN "
fi
2024-03-04 11:25:30 +01:00
# Set maintenance window so that no warning is shown in the admin overview
2024-07-26 12:57:40 +02:00
if [ -z " $NEXTCLOUD_MAINTENANCE_WINDOW " ] ; then
NEXTCLOUD_MAINTENANCE_WINDOW = 100
2024-03-04 11:25:30 +01:00
fi
2024-07-26 12:57:40 +02:00
php /var/www/html/occ config:system:set maintenance_window_start --type= int --value= " $NEXTCLOUD_MAINTENANCE_WINDOW "
2022-05-25 15:15:52 +02:00
2021-11-30 11:20:42 +01:00
# Apply network settings
echo "Applying network settings..."
2023-12-06 14:37:20 +01:00
php /var/www/html/occ config:system:set allow_local_remote_servers --type= bool --value= true
2023-08-10 09:14:07 +02:00
php /var/www/html/occ config:system:set davstorage.request_timeout --value= " $PHP_MAX_TIME " --type= int
2021-11-30 11:20:42 +01:00
php /var/www/html/occ config:system:set trusted_domains 1 --value= " $NC_DOMAIN "
php /var/www/html/occ config:system:set overwrite.cli.url --value= " https:// $NC_DOMAIN / "
2024-10-16 12:30:31 +02:00
php /var/www/html/occ config:system:set documentation_url.server_logs --value= "https://github.com/nextcloud/all-in-one/discussions/5425"
2021-11-30 11:20:42 +01:00
php /var/www/html/occ config:system:set htaccess.RewriteBase --value= "/"
php /var/www/html/occ maintenance:update:htaccess
2023-10-03 23:21:00 +02:00
# Revert dbpersistent setting to check if it fixes too many db connections
php /var/www/html/occ config:system:set dbpersistent --value= false --type= bool
2023-08-10 10:38:27 +02:00
2024-04-11 13:27:44 +02:00
if [ " $DISABLE_BRUTEFORCE_PROTECTION " = yes ] ; then
php /var/www/html/occ config:system:set auth.bruteforce.protection.enabled --type= bool --value= false
php /var/www/html/occ config:system:set ratelimit.protection.enabled --type= bool --value= false
else
php /var/www/html/occ config:system:set auth.bruteforce.protection.enabled --type= bool --value= true
php /var/www/html/occ config:system:set ratelimit.protection.enabled --type= bool --value= true
fi
2022-03-14 15:35:37 +01:00
# Disallow creating local external storages when nothing was mounted
if [ -z " $NEXTCLOUD_MOUNT " ] ; then
php /var/www/html/occ config:system:set files_external_allow_create_new_local --type= bool --value= false
else
php /var/www/html/occ config:system:set files_external_allow_create_new_local --type= bool --value= true
fi
2024-02-28 19:08:00 +01:00
# AIO app start # Do not remove or change this line!
2021-11-30 12:50:08 +01:00
# AIO app
2023-11-13 15:53:17 +01:00
if [ " $THIS_IS_AIO " = "true" ] ; then
if [ " $( php /var/www/html/occ config:app:get nextcloud-aio enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable nextcloud-aio
fi
else
if [ " $( php /var/www/html/occ config:app:get nextcloud-aio enabled) " != "no" ] ; then
php /var/www/html/occ app:disable nextcloud-aio
fi
2021-11-30 12:50:08 +01:00
fi
2024-02-28 19:08:00 +01:00
# AIO app end # Do not remove or change this line!
2021-11-30 12:50:08 +01:00
2021-11-30 11:20:42 +01:00
# Notify push
if ! [ -d "/var/www/html/custom_apps/notify_push" ] ; then
php /var/www/html/occ app:install notify_push
2023-01-10 12:32:33 +01:00
elif [ " $( php /var/www/html/occ config:app:get notify_push enabled) " != "yes" ] ; then
2021-11-30 11:20:42 +01:00
php /var/www/html/occ app:enable notify_push
2022-10-27 13:50:26 +02:00
elif [ " $SKIP_UPDATE " != 1 ] ; then
2021-11-30 11:20:42 +01:00
php /var/www/html/occ app:update notify_push
fi
2023-11-16 17:13:47 +01:00
chmod 775 -R /var/www/html/custom_apps/notify_push/bin/
2022-02-22 13:26:48 +01:00
php /var/www/html/occ config:system:set trusted_proxies 0 --value= "127.0.0.1"
2022-06-15 12:42:14 +02:00
php /var/www/html/occ config:system:set trusted_proxies 1 --value= "::1"
2023-11-21 17:34:37 +01:00
if [ -n " $ADDITIONAL_TRUSTED_PROXY " ] ; then
2024-04-25 16:51:33 +02:00
php /var/www/html/occ config:system:set trusted_proxies 2 --value= " $ADDITIONAL_TRUSTED_PROXY "
2023-11-21 17:34:37 +01:00
fi
2024-04-25 16:51:33 +02:00
2024-11-28 10:59:41 +01:00
# Get ipv4-address of Nextcloud
if [ -z " $NEXTCLOUD_HOST " ] ; then
export NEXTCLOUD_HOST = "nextcloud-aio-nextcloud"
fi
IPv4_ADDRESS = " $( dig " $NEXTCLOUD_HOST " A +short +search | head -1) "
2024-04-25 16:51:33 +02:00
# Bring it in CIDR notation
# shellcheck disable=SC2001
2024-06-14 10:04:01 +02:00
IPv4_ADDRESS = " $( echo " $IPv4_ADDRESS " | sed 's|[0-9]\+$|0/16|' ) "
2024-11-28 10:59:41 +01:00
if [ -n " $IPv4_ADDRESS " ] ; then
php /var/www/html/occ config:system:set trusted_proxies 10 --value= " $IPv4_ADDRESS "
fi
2024-04-25 16:51:33 +02:00
2024-02-01 13:25:22 +01:00
if [ -n " $ADDITIONAL_TRUSTED_DOMAIN " ] ; then
php /var/www/html/occ config:system:set trusted_domains 2 --value= " $ADDITIONAL_TRUSTED_DOMAIN "
fi
2021-11-30 11:20:42 +01:00
php /var/www/html/occ config:app:set notify_push base_endpoint --value= " https:// $NC_DOMAIN /push "
# Collabora
2022-03-17 10:13:21 +01:00
if [ " $COLLABORA_ENABLED " = 'yes' ] ; then
2024-03-28 12:49:52 +01:00
set -x
2024-03-28 15:53:57 +01:00
if echo " $COLLABORA_HOST " | grep -q "nextcloud-.*-collabora" ; then
2024-03-28 12:49:52 +01:00
COLLABORA_HOST = " $NC_DOMAIN "
fi
set +x
2024-08-30 16:56:46 +02:00
# Remove richdcoumentscode if it should be incorrectly installed
if [ -d "/var/www/html/custom_apps/richdocumentscode" ] ; then
php /var/www/html/occ app:remove richdocumentscode
fi
2022-03-17 10:13:21 +01:00
if ! [ -d "/var/www/html/custom_apps/richdocuments" ] ; then
php /var/www/html/occ app:install richdocuments
2023-01-10 12:32:33 +01:00
elif [ " $( php /var/www/html/occ config:app:get richdocuments enabled) " != "yes" ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:enable richdocuments
2022-10-27 13:50:26 +02:00
elif [ " $SKIP_UPDATE " != 1 ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:update richdocuments
fi
2024-03-28 12:49:52 +01:00
php /var/www/html/occ config:app:set richdocuments wopi_url --value= " https:// $COLLABORA_HOST / "
2022-12-09 12:42:15 +01:00
# Make collabora more save
2024-03-28 12:49:52 +01:00
COLLABORA_IPv4_ADDRESS = " $( dig " $COLLABORA_HOST " A +short +search | grep '^[0-9.]\+$' | sort | head -n1) "
COLLABORA_IPv6_ADDRESS = " $( dig " $COLLABORA_HOST " AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1) "
2022-12-09 12:42:15 +01:00
COLLABORA_ALLOW_LIST = " $( php /var/www/html/occ config:app:get richdocuments wopi_allowlist) "
if [ -n " $COLLABORA_IPv4_ADDRESS " ] ; then
if ! echo " $COLLABORA_ALLOW_LIST " | grep -q " $COLLABORA_IPv4_ADDRESS " ; then
if [ -z " $COLLABORA_ALLOW_LIST " ] ; then
COLLABORA_ALLOW_LIST = " $COLLABORA_IPv4_ADDRESS "
else
COLLABORA_ALLOW_LIST += " , $COLLABORA_IPv4_ADDRESS "
fi
fi
else
2025-09-26 15:27:56 -04:00
echo " Warning: No IPv4 address found for $COLLABORA_HOST . "
2022-12-09 12:42:15 +01:00
fi
if [ -n " $COLLABORA_IPv6_ADDRESS " ] ; then
if ! echo " $COLLABORA_ALLOW_LIST " | grep -q " $COLLABORA_IPv6_ADDRESS " ; then
if [ -z " $COLLABORA_ALLOW_LIST " ] ; then
COLLABORA_ALLOW_LIST = " $COLLABORA_IPv6_ADDRESS "
else
COLLABORA_ALLOW_LIST += " , $COLLABORA_IPv6_ADDRESS "
fi
fi
else
2025-09-26 15:27:56 -04:00
echo " No IPv6 address found for $COLLABORA_HOST . "
2022-12-09 12:42:15 +01:00
fi
if [ -n " $COLLABORA_ALLOW_LIST " ] ; then
2025-11-26 12:41:00 +01:00
PRIVATE_IP_RANGES = '127.0.0.0/8,192.168.0.0/16,172.16.0.0/12,10.0.0.0/8,100.64.0.0/10,fd00::/8,::1/128'
2023-02-21 17:31:03 +01:00
if ! echo " $COLLABORA_ALLOW_LIST " | grep -q " $PRIVATE_IP_RANGES " ; then
COLLABORA_ALLOW_LIST += " , $PRIVATE_IP_RANGES "
fi
2023-11-21 17:34:37 +01:00
if [ -n " $ADDITIONAL_TRUSTED_PROXY " ] ; then
if ! echo " $COLLABORA_ALLOW_LIST " | grep -q " $ADDITIONAL_TRUSTED_PROXY " ; then
COLLABORA_ALLOW_LIST += " , $ADDITIONAL_TRUSTED_PROXY "
fi
fi
2022-12-09 12:42:15 +01:00
php /var/www/html/occ config:app:set richdocuments wopi_allowlist --value= " $COLLABORA_ALLOW_LIST "
else
2025-09-26 15:27:56 -04:00
echo "Warning: wopi_allowlist is empty; this should not be the case!"
2022-12-09 12:42:15 +01:00
fi
2021-11-30 11:20:42 +01:00
else
2023-07-19 21:29:24 +02:00
if [ " $REMOVE_DISABLED_APPS " = yes ] && [ -d "/var/www/html/custom_apps/richdocuments" ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:remove richdocuments
fi
fi
# OnlyOffice
if [ " $ONLYOFFICE_ENABLED " = 'yes' ] ; then
2025-09-26 15:27:56 -04:00
# Determine OnlyOffice port based on host pattern
2025-06-16 14:21:05 +02:00
if echo " $ONLYOFFICE_HOST " | grep -q "nextcloud-.*-onlyoffice" ; then
ONLYOFFICE_PORT = 80
else
ONLYOFFICE_PORT = 443
fi
2025-09-26 15:27:56 -04:00
2025-11-18 12:13:50 +01:00
count = 0
while ! nc -z " $ONLYOFFICE_HOST " " $ONLYOFFICE_PORT " && [ " $count " -lt 90 ] ; do
2025-09-26 15:27:56 -04:00
echo "Waiting for OnlyOffice to become available..."
2025-11-18 12:13:50 +01:00
count = $(( count+5))
2022-03-22 19:34:16 +01:00
sleep 5
done
2025-11-18 12:13:50 +01:00
if [ " $count " -ge 90 ] ; then
bash /notify.sh "Onlyoffice did not start in time!" "Skipping initialization and disabling onlyoffice app."
php /var/www/html/occ app:disable onlyoffice
else
# Install or enable OnlyOffice app as needed
if ! [ -d "/var/www/html/custom_apps/onlyoffice" ] ; then
php /var/www/html/occ app:install onlyoffice
elif [ " $( php /var/www/html/occ config:app:get onlyoffice enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable onlyoffice
elif [ " $SKIP_UPDATE " != 1 ] ; then
php /var/www/html/occ app:update onlyoffice
fi
2025-09-26 15:27:56 -04:00
2025-11-18 12:13:50 +01:00
# Set OnlyOffice configuration
2025-12-17 15:11:24 +01:00
php /var/www/html/occ config:system:set onlyoffice editors_check_interval --value= "0" --type= integer
2025-11-18 12:13:50 +01:00
php /var/www/html/occ config:system:set onlyoffice jwt_secret --value= " $ONLYOFFICE_SECRET "
php /var/www/html/occ config:app:set onlyoffice jwt_secret --value= " $ONLYOFFICE_SECRET "
php /var/www/html/occ config:system:set onlyoffice jwt_header --value= "AuthorizationJwt"
2025-09-26 15:27:56 -04:00
2025-11-18 12:13:50 +01:00
# Adjust the OnlyOffice host if using internal pattern
if echo " $ONLYOFFICE_HOST " | grep -q "nextcloud-.*-onlyoffice" ; then
ONLYOFFICE_HOST = " $NC_DOMAIN /onlyoffice "
export ONLYOFFICE_HOST
fi
2025-09-26 15:27:56 -04:00
2025-11-18 12:13:50 +01:00
php /var/www/html/occ config:app:set onlyoffice DocumentServerUrl --value= " https:// $ONLYOFFICE_HOST "
2025-06-16 14:21:05 +02:00
fi
2022-03-17 10:13:21 +01:00
else
2025-09-26 15:27:56 -04:00
# Remove OnlyOffice app if disabled and removal is requested
if [ " $REMOVE_DISABLED_APPS " = yes ] && \
[ -d "/var/www/html/custom_apps/onlyoffice" ] && \
[ -n " $ONLYOFFICE_SECRET " ] && \
[ " $( php /var/www/html/occ config:system:get onlyoffice jwt_secret) " = " $ONLYOFFICE_SECRET " ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:remove onlyoffice
fi
2021-11-30 11:20:42 +01:00
fi
# Talk
2022-03-17 10:13:21 +01:00
if [ " $TALK_ENABLED " = 'yes' ] ; then
2024-04-04 12:45:07 +02:00
set -x
if [ -z " $TALK_HOST " ] || echo " $TALK_HOST " | grep -q "nextcloud-.*-talk" ; then
TALK_HOST = " $NC_DOMAIN "
HPB_PATH = "/standalone-signaling/"
fi
2024-04-11 13:03:50 +02:00
if [ -z " $TURN_DOMAIN " ] ; then
TURN_DOMAIN = " $TALK_HOST "
fi
2024-04-04 12:45:07 +02:00
set +x
2022-03-17 10:13:21 +01:00
if ! [ -d "/var/www/html/custom_apps/spreed" ] ; then
php /var/www/html/occ app:install spreed
2023-01-10 12:32:33 +01:00
elif [ " $( php /var/www/html/occ config:app:get spreed enabled) " != "yes" ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:enable spreed
2022-10-27 13:50:26 +02:00
elif [ " $SKIP_UPDATE " != 1 ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:update spreed
fi
2022-10-24 21:38:17 +02:00
# Based on https://github.com/nextcloud/spreed/issues/960#issuecomment-416993435
2022-10-25 21:03:10 +02:00
if [ -z " $( php /var/www/html/occ talk:turn:list --output= "plain" ) " ] ; then
2024-04-04 14:39:24 +02:00
# shellcheck disable=SC2153
2024-04-11 13:03:50 +02:00
php /var/www/html/occ talk:turn:add turn " $TURN_DOMAIN : $TALK_PORT " "udp,tcp" --secret= " $TURN_SECRET "
2022-10-24 21:38:17 +02:00
fi
2023-03-21 19:17:41 +01:00
STUN_SERVER = " $( php /var/www/html/occ talk:stun:list --output= "plain" ) "
if [ -z " $STUN_SERVER " ] || echo " $STUN_SERVER " | grep -oP '[a-zA-Z.:0-9]+' | grep -q " ^stun.nextcloud.com:443 $" ; then
2024-04-11 13:03:50 +02:00
php /var/www/html/occ talk:stun:add " $TURN_DOMAIN : $TALK_PORT "
2022-10-25 21:03:10 +02:00
php /var/www/html/occ talk:stun:delete "stun.nextcloud.com:443"
2022-10-24 21:38:17 +02:00
fi
2024-04-04 12:45:07 +02:00
if ! php /var/www/html/occ talk:signaling:list --output= "plain" | grep -q " https:// $TALK_HOST $HPB_PATH " ; then
php /var/www/html/occ talk:signaling:add " https:// $TALK_HOST $HPB_PATH " " $SIGNALING_SECRET " --verify
2022-10-24 21:38:17 +02:00
fi
2021-11-30 11:20:42 +01:00
else
2023-07-19 21:29:24 +02:00
if [ " $REMOVE_DISABLED_APPS " = yes ] && [ -d "/var/www/html/custom_apps/spreed" ] ; then
2022-03-17 10:13:21 +01:00
php /var/www/html/occ app:remove spreed
fi
2021-11-30 11:20:42 +01:00
fi
2021-12-07 18:45:52 +01:00
2023-06-05 15:05:14 +02:00
# Talk recording
if [ -d "/var/www/html/custom_apps/spreed" ] ; then
if [ " $TALK_RECORDING_ENABLED " = 'yes' ] ; then
2023-06-06 09:26:14 +02:00
while ! nc -z " $TALK_RECORDING_HOST " 1234; do
2025-09-26 15:27:56 -04:00
echo "Waiting for Talk Recording to become available..."
2023-06-06 09:26:14 +02:00
sleep 5
done
2023-06-05 15:05:14 +02:00
# TODO: migrate to occ command if that becomes available
2023-06-05 18:44:36 +02:00
RECORDING_SERVERS_STRING = " {\"servers\":[{\"server\":\"http:// $TALK_RECORDING_HOST :1234/\",\"verify\":true}],\"secret\":\" $RECORDING_SECRET \"} "
2023-06-05 15:05:14 +02:00
php /var/www/html/occ config:app:set spreed recording_servers --value= " $RECORDING_SERVERS_STRING "
else
php /var/www/html/occ config:app:delete spreed recording_servers
fi
fi
2022-03-15 23:46:58 +01:00
# Clamav
if [ " $CLAMAV_ENABLED " = 'yes' ] ; then
2023-03-02 09:21:45 +01:00
count = 0
while ! nc -z " $CLAMAV_HOST " 3310 && [ " $count " -lt 90 ] ; do
2025-09-26 15:27:56 -04:00
echo "Waiting for ClamAV to become available..."
2023-03-02 09:21:45 +01:00
count = $(( count+5))
2022-03-16 22:28:17 +01:00
sleep 5
done
2023-03-02 09:21:45 +01:00
if [ " $count " -ge 90 ] ; then
2025-11-18 12:13:50 +01:00
bash /notify.sh "ClamAV did not start in time!" "Skipping initialization and disabling files_antivirus app."
2023-03-02 09:21:45 +01:00
php /var/www/html/occ app:disable files_antivirus
else
if ! [ -d "/var/www/html/custom_apps/files_antivirus" ] ; then
php /var/www/html/occ app:install files_antivirus
elif [ " $( php /var/www/html/occ config:app:get files_antivirus enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable files_antivirus
elif [ " $SKIP_UPDATE " != 1 ] ; then
php /var/www/html/occ app:update files_antivirus
fi
php /var/www/html/occ config:app:set files_antivirus av_mode --value= "daemon"
php /var/www/html/occ config:app:set files_antivirus av_port --value= "3310"
php /var/www/html/occ config:app:set files_antivirus av_host --value= " $CLAMAV_HOST "
2025-11-11 09:35:47 +01:00
# av_stream_max_length must be synced with StreamMaxLength inside clamav
php /var/www/html/occ config:app:set files_antivirus av_stream_max_length --value= "2147483648"
2025-10-17 12:21:33 +02:00
php /var/www/html/occ config:app:set files_antivirus av_max_file_size --value= "-1"
2023-03-02 09:21:45 +01:00
php /var/www/html/occ config:app:set files_antivirus av_infected_action --value= "only_log"
2025-09-26 11:47:49 +02:00
if [ -n " $CLAMAV_BLOCKLISTED_DIRECTORIES " ] ; then
php /var/www/html/occ config:app:set files_antivirus av_blocklisted_directories --value= " $CLAMAV_BLOCKLISTED_DIRECTORIES "
fi
2022-03-15 23:46:58 +01:00
fi
else
2023-07-19 21:29:24 +02:00
if [ " $REMOVE_DISABLED_APPS " = yes ] && [ -d "/var/www/html/custom_apps/files_antivirus" ] ; then
2022-03-15 23:46:58 +01:00
php /var/www/html/occ app:remove files_antivirus
fi
fi
2022-08-17 15:09:22 +02:00
# Imaginary
2023-05-26 12:36:00 +02:00
if [ " $IMAGINARY_ENABLED " = 'yes' ] ; then
php /var/www/html/occ config:system:set enabledPreviewProviders 0 --value= "OC\\Preview\\Imaginary"
2024-11-28 11:15:31 +01:00
php /var/www/html/occ config:system:set enabledPreviewProviders 23 --value= "OC\\Preview\\ImaginaryPDF"
2023-05-26 12:36:00 +02:00
php /var/www/html/occ config:system:set preview_imaginary_url --value= " http:// $IMAGINARY_HOST :9000 "
2024-03-04 11:48:21 +01:00
php /var/www/html/occ config:system:set preview_imaginary_key --value= " $IMAGINARY_SECRET "
2023-05-26 12:36:00 +02:00
else
if [ -n " $( php /var/www/html/occ config:system:get preview_imaginary_url) " ] ; then
php /var/www/html/occ config:system:delete enabledPreviewProviders 0
php /var/www/html/occ config:system:delete preview_imaginary_url
php /var/www/html/occ config:system:delete enabledPreviewProviders 20
php /var/www/html/occ config:system:delete enabledPreviewProviders 21
php /var/www/html/occ config:system:delete enabledPreviewProviders 22
2024-11-28 11:15:31 +01:00
php /var/www/html/occ config:system:delete enabledPreviewProviders 23
2022-08-17 15:09:22 +02:00
fi
fi
2022-08-22 13:04:44 +02:00
# Fulltextsearch
if [ " $FULLTEXTSEARCH_ENABLED " = 'yes' ] ; then
2025-08-13 14:05:31 +02:00
count = 0
while ! nc -z " $FULLTEXTSEARCH_HOST " " $FULLTEXTSEARCH_PORT " && [ " $count " -lt 90 ] ; do
2025-09-26 15:27:56 -04:00
echo "Waiting for Fulltextsearch to become available..."
2025-08-13 14:05:31 +02:00
count = $(( count+5))
2022-08-22 13:04:44 +02:00
sleep 5
done
2025-08-13 14:05:31 +02:00
if [ " $count " -ge 90 ] ; then
echo "Fulltextsearch did not start in time. Skipping initialization and disabling fulltextsearch apps."
php /var/www/html/occ app:disable fulltextsearch
php /var/www/html/occ app:disable fulltextsearch_elasticsearch
php /var/www/html/occ app:disable files_fulltextsearch
else
2025-12-16 10:40:45 +01:00
if [ -z " $FULLTEXTSEARCH_PROTOCOL " ] ; then
FULLTEXTSEARCH_PROTOCOL = "http"
fi
2025-08-13 14:05:31 +02:00
if ! [ -d "/var/www/html/custom_apps/fulltextsearch" ] ; then
php /var/www/html/occ app:install fulltextsearch
elif [ " $( php /var/www/html/occ config:app:get fulltextsearch enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable fulltextsearch
elif [ " $SKIP_UPDATE " != 1 ] ; then
php /var/www/html/occ app:update fulltextsearch
fi
if ! [ -d "/var/www/html/custom_apps/fulltextsearch_elasticsearch" ] ; then
php /var/www/html/occ app:install fulltextsearch_elasticsearch
elif [ " $( php /var/www/html/occ config:app:get fulltextsearch_elasticsearch enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable fulltextsearch_elasticsearch
elif [ " $SKIP_UPDATE " != 1 ] ; then
php /var/www/html/occ app:update fulltextsearch_elasticsearch
fi
if ! [ -d "/var/www/html/custom_apps/files_fulltextsearch" ] ; then
php /var/www/html/occ app:install files_fulltextsearch
elif [ " $( php /var/www/html/occ config:app:get files_fulltextsearch enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable files_fulltextsearch
elif [ " $SKIP_UPDATE " != 1 ] ; then
php /var/www/html/occ app:update files_fulltextsearch
fi
php /var/www/html/occ fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}'
2025-12-16 10:40:45 +01:00
php /var/www/html/occ fulltextsearch_elasticsearch:configure " {\"elastic_host\":\" $FULLTEXTSEARCH_PROTOCOL :// $FULLTEXTSEARCH_USER : $FULLTEXTSEARCH_PASSWORD @ $FULLTEXTSEARCH_HOST : $FULLTEXTSEARCH_PORT \",\"elastic_index\":\" $FULLTEXTSEARCH_INDEX \"} "
2025-11-13 11:42:57 +01:00
php /var/www/html/occ files_fulltextsearch:configure "{\"files_pdf\":true,\"files_office\":true}"
2025-08-13 14:05:31 +02:00
# Do the index
if ! [ -f " $NEXTCLOUD_DATA_DIR /fts-index.done " ] ; then
2025-09-26 15:27:56 -04:00
echo "Waiting 10 seconds before activating fulltextsearch..."
2025-08-13 14:05:31 +02:00
sleep 10
echo "Activating fulltextsearch..."
if php /var/www/html/occ fulltextsearch:test && php /var/www/html/occ fulltextsearch:index "{\"errors\": \"reset\"}" --no-readline; then
touch " $NEXTCLOUD_DATA_DIR /fts-index.done "
else
echo "Fulltextsearch failed. Could not index."
2025-09-26 15:27:56 -04:00
echo "If you want to skip indexing in the future, see https://github.com/nextcloud/all-in-one/discussions/1709"
2025-08-13 14:05:31 +02:00
fi
2022-08-26 13:59:04 +02:00
fi
fi
2022-08-22 13:04:44 +02:00
else
2023-07-19 21:29:24 +02:00
if [ " $REMOVE_DISABLED_APPS " = yes ] ; then
if [ -d "/var/www/html/custom_apps/fulltextsearch" ] ; then
php /var/www/html/occ app:remove fulltextsearch
fi
if [ -d "/var/www/html/custom_apps/fulltextsearch_elasticsearch" ] ; then
php /var/www/html/occ app:remove fulltextsearch_elasticsearch
fi
if [ -d "/var/www/html/custom_apps/files_fulltextsearch" ] ; then
php /var/www/html/occ app:remove files_fulltextsearch
fi
2022-08-22 13:04:44 +02:00
fi
fi
2023-08-24 14:09:21 +02:00
# Docker socket proxy
2025-01-07 15:21:42 +01:00
# app_api is a shipped app
if [ -d "/var/www/html/custom_apps/app_api" ] ; then
php /var/www/html/occ app:disable app_api
rm -r "/var/www/html/custom_apps/app_api"
fi
2024-08-07 13:30:23 +02:00
if [ " $DOCKER_SOCKET_PROXY_ENABLED " = 'yes' ] ; then
2025-01-07 15:21:42 +01:00
if [ " $( php /var/www/html/occ config:app:get app_api enabled) " != "yes" ] ; then
2024-08-07 13:30:23 +02:00
php /var/www/html/occ app:enable app_api
fi
else
2025-01-07 15:21:42 +01:00
if [ " $REMOVE_DISABLED_APPS " = yes ] ; then
if [ " $( php /var/www/html/occ config:app:get app_api enabled) " != "no" ] ; then
php /var/www/html/occ app:disable app_api
fi
2023-08-24 14:09:21 +02:00
fi
fi
2024-09-16 17:59:15 +02:00
# Whiteboard app
if [ " $WHITEBOARD_ENABLED " = 'yes' ] ; then
if ! [ -d "/var/www/html/custom_apps/whiteboard" ] ; then
php /var/www/html/occ app:install whiteboard
elif [ " $( php /var/www/html/occ config:app:get whiteboard enabled) " != "yes" ] ; then
php /var/www/html/occ app:enable whiteboard
elif [ " $SKIP_UPDATE " != 1 ] ; then
php /var/www/html/occ app:update whiteboard
fi
2024-09-17 11:44:17 +02:00
php /var/www/html/occ config:app:set whiteboard collabBackendUrl --value= " https:// $NC_DOMAIN /whiteboard "
2024-09-17 10:43:22 +02:00
php /var/www/html/occ config:app:set whiteboard jwt_secret_key --value= " $WHITEBOARD_SECRET "
2024-09-16 17:59:15 +02:00
else
if [ " $REMOVE_DISABLED_APPS " = yes ] && [ -d "/var/www/html/custom_apps/whiteboard" ] ; then
php /var/www/html/occ app:remove whiteboard
fi
fi
2021-12-07 18:45:52 +01:00
# Remove the update skip file always
2022-09-20 16:33:43 +02:00
rm -f " $NEXTCLOUD_DATA_DIR " /skip.update