mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
more generic SQL
This commit is contained in:
parent
e571dcc9fa
commit
663ede2773
4 changed files with 13 additions and 9 deletions
|
@ -62,15 +62,16 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
|||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
# BACKUP THE SQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
if [ $database == "pgsql" ]
|
||||
then
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
else
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -74,19 +74,20 @@ ynh_script_progression --message="Configuring system user..." --weight=1
|
|||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
# CREATE A SQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
|
||||
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
if [ $database == "pgsql" ]
|
||||
then
|
||||
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
else
|
||||
ynh_script_progression --message="Creating a MySQL database..." --weight=2
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
fi
|
||||
|
|
|
@ -34,15 +34,16 @@ ynh_script_progression --message="Removing logrotate configuration..."
|
|||
ynh_remove_logrotate
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
# REMOVE THE SQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
if [ $database == "pgsql" ]
|
||||
then
|
||||
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=2
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
else
|
||||
ynh_script_progression --message="Removing the MySQL database..." --weight=2
|
||||
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
fi
|
||||
|
||||
|
|
|
@ -92,17 +92,18 @@ fi
|
|||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
# RESTORE THE SQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
|
||||
|
||||
if [ $database == "pgsql" ]
|
||||
then
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||
else
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=6
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||
|
|
Loading…
Add table
Reference in a new issue