diff --git a/conf/config.sample.yml b/conf/config.sample.yml index d071523..c5a85c1 100644 --- a/conf/config.sample.yml +++ b/conf/config.sample.yml @@ -30,8 +30,8 @@ bindIP: 0.0.0.0 db: type: mysql # PostgreSQL / MySQL / MariaDB / MS SQL Server only: - host: localhost - port: 3306 + host: postgres + port: 5432 user: __DB_NAME__ pass: __DB_PWD__ db: __DB_NAME__ diff --git a/manifest.json b/manifest.json index 74cb63c..20f416c 100644 --- a/manifest.json +++ b/manifest.json @@ -19,8 +19,7 @@ }, "multi_instance": true, "services": [ - "nginx", - "mysql" + "nginx" ], "arguments": { "install" : [ diff --git a/scripts/backup b/scripts/backup index 130811c..23fb154 100644 --- a/scripts/backup +++ b/scripts/backup @@ -51,10 +51,10 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #ynh_backup "/etc/php5/fpm/pool.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_mysql_dump_db "$db_name" > db.sql +ynh_psql_dump_db "$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index d880c3e..10599d9 100644 --- a/scripts/install +++ b/scripts/install @@ -100,7 +100,7 @@ ynh_install_app_dependencies redis-server ynh_install_nodejs 10 #================================================= -# CREATE A MYSQL DATABASE +# CREATE A POSTGRESQL DATABASE #================================================= ### Use these lines if you need a database for the application. @@ -108,13 +108,17 @@ ynh_install_nodejs 10 ### The password will be stored as 'mysqlpwd' into the app settings, ### and will be available as $db_pwd ### If you're not using these lines: -### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script -### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script -### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script +### - Remove the section "BACKUP THE POSTGRESQL DATABASE" in the backup script +### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script +### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +db_pwd=$(ynh_string_random 30) +ynh_app_setting_set "$app" psql_db "$db_name" +ynh_app_setting_set "$app" psqlpwd "$db_pwd" +ynh_psql_test_if_first_run +ynh_psql_create_user "$db_name" "$db_pwd" +ynh_psql_create_db "$db_name" "$db_name" "$db_pwd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/remove b/scripts/remove index ebe12c3..bb78a1b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -51,11 +51,11 @@ ynh_use_nodejs ynh_remove_nodejs #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE THE POSTGRESQL DATABASE #================================================= # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_user $db_name +ynh_psql_remove_db "$db_name" "$db_name" #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index eeda022..53a54bd 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,12 +55,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "$final_path" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE POSTGRESQL DATABASE #================================================= -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +ynh_install_app_dependencies postgresql postgresql-contrib +ynh_psql_test_if_first_run +ynh_psql_create_user "$db_name" "$db_pwd" +ynh_psql_create_db "$db_name" "$db_name" "$db_pwd" +ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= # RECREATE THE DEDICATED USER