diff --git a/check_process b/check_process index 8d88180..3c0df0d 100644 --- a/check_process +++ b/check_process @@ -13,6 +13,7 @@ setup_public=0 upgrade=1 upgrade=1 from_commit=c864e086625363d91dde6ba78a652011a991a027 + upgrade=1 from_commit=e9e7015ed7667352c1c191fc632a9f6f382dd9d2 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -25,3 +26,6 @@ Notification=none ; commit=c864e086625363d91dde6ba78a652011a991a027 name=[fix] php7.2-mcrypt doesn't exist (#253) manifest_arg=domain=DOMAIN&path=PATH&admin=USER&user_home=1& + ; commit=e9e7015ed7667352c1c191fc632a9f6f382dd9d2 + name=[fix] Upgrade to 20.0.4 (#346) + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&user_home=1& \ No newline at end of file diff --git a/manifest.json b/manifest.json index ccc8955..51ab208 100644 --- a/manifest.json +++ b/manifest.json @@ -27,8 +27,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.3-fpm", - "mysql" + "php7.3-fpm" ], "arguments": { "install" : [ diff --git a/scripts/_common.sh b/scripts/_common.sh index c4e3403..d545d90 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,10 +3,10 @@ # COMMON VARIABLES #================================================= -pkg_dependencies="imagemagick acl tar smbclient at" +pkg_dependencies="imagemagick acl tar smbclient at postgresql" YNH_PHP_VERSION="7.3" -extra_php_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-smbclient php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-bcmath" +extra_php_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-smbclient php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-igbinary php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-pgsql" #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/backup b/scripts/backup index 7ed3c7f..10e0fd8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -52,11 +52,11 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the MySQL database..." +ynh_print_info --message="Backing up the PostgreSQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index bb5e844..28655ee 100755 --- a/scripts/install +++ b/scripts/install @@ -58,13 +58,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=10 ynh_install_app_dependencies $pkg_dependencies #================================================= -# CREATE A MYSQL DATABASE +# CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." --weight=2 +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -156,7 +157,7 @@ admin_password="$(ynh_string_random --length=6)" # Install Nextcloud using a temporary admin user exec_occ maintenance:install \ - --database "mysql" --database-name $db_name \ + --database "pgsql" --database-name $db_name \ --database-user $db_name --database-pass "$db_pwd" \ --admin-user "admin" --admin-pass "$admin_password" \ --data-dir "$datadir" \ @@ -252,7 +253,7 @@ exec_occ config:system:set overwrite.cli.url --value="https://${domain}" #================================================= # Set the user as admin -ynh_mysql_connect_as --user=$db_name --password="$db_pwd" --database=$db_name \ +ynh_psql_connect_as --user=$db_name --password="$db_pwd" --database=$db_name \ <<< "INSERT INTO oc_group_user VALUES ('admin','$admin');" # And delete admin user exec_occ user:delete admin diff --git a/scripts/remove b/scripts/remove index b84d5bf..4c3e371 100755 --- a/scripts/remove +++ b/scripts/remove @@ -31,12 +31,12 @@ ynh_script_progression --message="Removing dependencies..." --weight=20 ynh_remove_app_dependencies #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=5 +ynh_script_progression --message="Removing the PostgreSQL database..." --weight=5 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name +ynh_psql_remove_db --db_user=$db_name --db_name=$db_name #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index 44f8384..8e6f5ee 100755 --- a/scripts/restore +++ b/scripts/restore @@ -44,6 +44,14 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=10 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -67,13 +75,15 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=9 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=9 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_test_if_first_run +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +# Restore dump +ynh_psql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RECREATE THE DEDICATED USER @@ -85,14 +95,6 @@ ynh_system_user_create --username=$app #================================================= # SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 39b124d..3baf8b0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -94,6 +94,9 @@ then ynh_app_setting_delete $app backup_core_only ynh_clean_setup () { + # Remove both databases in case script fails during database migration + ynh_exec_warn_less ynh_psql_remove_db --db_user=$db_name --db_name=$db_name + ynh_exec_warn_less ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name # restore it if the upgrade fails ynh_restore_upgradebackup } @@ -211,6 +214,28 @@ local mount_id=$(exec_occ files_external:create --output=json \ # Define app's data directory datadir="/home/yunohost.app/$app/data" +#================================================= +# HANDLE DATABASE MIGRATION +#================================================= + +mysql_db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +if [ -n "$mysql_db_pwd" ] +then + ynh_script_progression --message="Migrate Database..." + + ynh_backup_if_checksum_is_different --file="$final_path/config/config.php" + + ynh_psql_test_if_first_run + ynh_psql_setup_db --db_user=$db_name --db_name=$db_name + + exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n + + ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name + ynh_app_setting_delete --app=$app --key=mysqlpwd + + ynh_store_file_checksum --file="${final_path}/config/config.php" +fi + if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading Nextcloud..." --weight=3