From 7f485eb9fa8cd5b807916a2cfda4fd90c3e9219f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Br=C3=BCckner?= Date: Wed, 12 Sep 2018 14:32:05 +0200 Subject: [PATCH] implement #455: auto-install via occ maintenance:install --- 12.0/apache/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 12.0/fpm-alpine/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 12.0/fpm/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 13.0/apache/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 13.0/fpm-alpine/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 13.0/fpm/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 14.0/apache/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 14.0/fpm-alpine/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 14.0/fpm/entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- docker-entrypoint.sh | 39 ++++++++++++++++++++++++++++++++++- 10 files changed, 380 insertions(+), 10 deletions(-) diff --git a/12.0/apache/entrypoint.sh b/12.0/apache/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/12.0/apache/entrypoint.sh +++ b/12.0/apache/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/12.0/fpm-alpine/entrypoint.sh b/12.0/fpm-alpine/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/12.0/fpm-alpine/entrypoint.sh +++ b/12.0/fpm-alpine/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/12.0/fpm/entrypoint.sh b/12.0/fpm/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/12.0/fpm/entrypoint.sh +++ b/12.0/fpm/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/13.0/apache/entrypoint.sh b/13.0/apache/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/13.0/apache/entrypoint.sh +++ b/13.0/apache/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/13.0/fpm-alpine/entrypoint.sh b/13.0/fpm-alpine/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/13.0/fpm-alpine/entrypoint.sh +++ b/13.0/fpm-alpine/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/13.0/fpm/entrypoint.sh b/13.0/fpm/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/13.0/fpm/entrypoint.sh +++ b/13.0/fpm/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/14.0/apache/entrypoint.sh b/14.0/apache/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/14.0/apache/entrypoint.sh +++ b/14.0/apache/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/14.0/fpm-alpine/entrypoint.sh b/14.0/fpm-alpine/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/14.0/fpm-alpine/entrypoint.sh +++ b/14.0/fpm-alpine/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/14.0/fpm/entrypoint.sh b/14.0/fpm/entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/14.0/fpm/entrypoint.sh +++ b/14.0/fpm/entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0afc0025..c31f4e93 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -49,13 +49,50 @@ if version_greater "$image_version" "$installed_version"; then fi done - if [ "$installed_version" != "0.0.0.0" ]; then + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ ! -z ${NEXTCLOUD_ADMIN_USER+x} ] && [ ! -z ${NEXTCLOUD_ADMIN_PASSWORD+x} ]; then + install_options="-n --admin-user \"$NEXTCLOUD_ADMIN_USER\" --admin-pass \"$NEXTCLOUD_ADMIN_PASSWORD\"" + if [ ! -z ${NEXTCLOUD_TABLE_PREFIX+x} ]; then + install_options="$install_options --database-table-prefix \"$NEXTCLOUD_TABLE_PREFIX\"" + fi + if [ ! -z ${NEXTCLOUD_DATA_DIR+x} ]; then + install_options="$install_options --data-dir \"$NEXTCLOUD_DATA_DIR\"" + fi + + if [ ! -z ${SQLITE_DATABASE+x} ]; then + echo "Installing with SQLite database" + install_options="$install_options --database-name \"$SQLITE_DATABASE\"" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${MYSQL_DATABASE+x} ] && [ ! -z ${MYSQL_USER+x} ] && [ ! -z ${MYSQL_PASSWORD+x} ] && [ ! -z ${MYSQL_HOST+x} ]; then + echo "Installing with MySQL database" + install_options="$install_options --database mysql --database-name \"$MYSQL_DATABASE\" --database-user \"$MYSQL_USER\" --database-pass \"$MYSQL_PASSWORD\" --database-host \"$MYSQL_HOST\"" + echo "waiting 30s for the database to setup" + sleep 30s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + elif [ ! -z ${POSTGRES_DB+x} ] && [ ! -z ${POSTGRES_USER+x} ] && [ ! -z ${POSTGRES_PASSWORD+x} ] && [ ! -z ${POSTGRES_HOST+x} ]; then + echo "Installing with PostgreSQL database" + install_options="$install_options --database pgsql --database-name \"$POSTGRES_DB\" --database-user \"$POSTGRES_USER\" --database-pass \"$POSTGRES_PASSWORD\" --database-host \"$POSTGRES_HOST\"" + echo "waiting 10s for the database to setup" + sleep 10s + echo "starting nexcloud installation" + run_as "php /var/www/html/occ maintenance:install $install_options" + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else run_as 'php /var/www/html/occ upgrade' run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after + fi fi