1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/paheko_ynh.git synced 2024-09-03 19:56:22 +02:00

comment db migration on experimental_heper

This commit is contained in:
rodinux 2023-01-15 16:30:16 +01:00
parent 4f8f1604a1
commit 349dff22fc
2 changed files with 23 additions and 28 deletions

View file

@ -192,35 +192,35 @@ ynh_handle_app_migration () {
# MOVE THE DATABASE # MOVE THE DATABASE
#================================================= #=================================================
db_pwd=$(ynh_app_setting_get $old_app mysqlpwd) # db_pwd=$(ynh_app_setting_get $old_app mysqlpwd)
db_name=$dbname # db_name=$dbname
# Check if a database exists before trying to move it # # Check if a database exists before trying to move it
local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE) # local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE)
if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name" # if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name"
then # then
new_db_name=$(ynh_sanitize_dbid $new_app) # new_db_name=$(ynh_sanitize_dbid $new_app)
echo "Rename the database $db_name to $new_db_name" >&2 # echo "Rename the database $db_name to $new_db_name" >&2
local sql_dump="/tmp/${db_name}-$(date '+%s').sql" # local sql_dump="/tmp/${db_name}-$(date '+%s').sql"
# Dump the old database # # Dump the old database
ynh_mysql_dump_db "$db_name" > "$sql_dump" # ynh_mysql_dump_db "$db_name" > "$sql_dump"
# Create a new database # # Create a new database
ynh_mysql_setup_db $new_db_name $new_db_name $db_pwd # ynh_mysql_setup_db $new_db_name $new_db_name $db_pwd
# Then restore the old one into the new one # # Then restore the old one into the new one
ynh_mysql_connect_as $new_db_name $db_pwd $new_db_name < "$sql_dump" # ynh_mysql_connect_as $new_db_name $db_pwd $new_db_name < "$sql_dump"
# Remove the old database # # Remove the old database
ynh_mysql_remove_db $db_name $db_name # ynh_mysql_remove_db $db_name $db_name
# And the dump # # And the dump
ynh_secure_remove --file="$sql_dump" # ynh_secure_remove --file="$sql_dump"
# Update the value of $db_name # # Update the value of $db_name
db_name=$new_db_name # db_name=$new_db_name
ynh_app_setting_set $new_app db_name $db_name # ynh_app_setting_set $new_app db_name $db_name
fi # fi
#================================================= #=================================================
# CHANGE THE FAKE DEPENDENCIES PACKAGE # CHANGE THE FAKE DEPENDENCIES PACKAGE

View file

@ -76,13 +76,8 @@ fi
ynh_handle_app_migration --migration_id=garradin --migration_list=garradin_migrations ynh_handle_app_migration --migration_id=garradin --migration_list=garradin_migrations
if [[ $migration_process -eq 1 ]]; then if [[ $migration_process -eq 1 ]]; then
# Reload variables
#dbname=$app
#db_user=$app
# Replace the user # Replace the user
ynh_system_user_delete --username="$old_app" ynh_system_user_delete --username="$old_app"
#test getent passwd "$app" &>/dev/null || \
useradd -d "$final_path" --system --user-group "$app" || \ useradd -d "$final_path" --system --user-group "$app" || \
ynh_die --message "Unable to create $app system account" ynh_die --message "Unable to create $app system account"