mirror of
https://github.com/YunoHost-Apps/paheko_ynh.git
synced 2024-09-03 19:56:22 +02:00
Some improvements and attempt to fix migration
This commit is contained in:
parent
b302d7f444
commit
ac5115e5a1
5 changed files with 45 additions and 29 deletions
|
@ -1,2 +1,7 @@
|
|||
# App main directory
|
||||
/var/www/$app
|
||||
|
||||
# NGINX web server configuration
|
||||
/etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
/etc/php/8.0/fpm/pool.d/$app.conf
|
|
@ -25,6 +25,12 @@ script_name="$0"
|
|||
ynh_secure_remove --file="/etc/yunohost/apps/$old_app"
|
||||
yunohost app ssowatconf
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE OLD USER
|
||||
#=================================================
|
||||
ynh_user_exists --username=$old_app && ynh_system_user_delete $old_app
|
||||
|
||||
#=================================================
|
||||
# DELETE THIS SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -198,8 +198,7 @@ ynh_handle_app_migration () {
|
|||
old_db_name=$(ynh_app_setting_get --app=$old_app --key=db_name)
|
||||
|
||||
# Check if a database exists before trying to move it
|
||||
local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE)
|
||||
if [ -n "$old_db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $old_db_name"
|
||||
if [ -n "$old_db_name" ] && mysqlshow | grep -q "^| $old_db_name"
|
||||
then
|
||||
old_db_user=$old_db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$old_app --key=mysqlpwd)
|
||||
|
|
|
@ -100,6 +100,7 @@ ynh_script_progression --message="Adding a configuration file..." --weight=5
|
|||
|
||||
# create a key for the secret key CSFR:
|
||||
secret_key=$(ynh_string_random --length=50)
|
||||
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
|
||||
|
||||
# Install configuration files
|
||||
ynh_add_config --template="config.local.php" --destination="$final_path/config.local.php"
|
||||
|
|
|
@ -39,9 +39,18 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
|||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
ynh_clean_setup_migration() {
|
||||
yunohost app remove $app
|
||||
app=garradin ynh_restore_upgradebackup
|
||||
}
|
||||
|
||||
ynh_clean_setup () {
|
||||
# Restore it if the upgrade fails
|
||||
ynh_restore_upgradebackup
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
ynh_clean_setup_migration
|
||||
else
|
||||
ynh_restore_upgradebackup
|
||||
fi
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -71,17 +80,13 @@ fi
|
|||
#=================================================
|
||||
|
||||
[[ $YNH_APP_ID == "garradin" ]] \
|
||||
&& [[ "$(cat "$final_path/VERSION")" != 1.2.2 ]] \
|
||||
&& ynh_die --message "It look like that you have an old Garradin install. You need first upgrade Garradin instance (id: $garradin_migrate_id) and after migrate to Paheko."
|
||||
&& [[ "$(cat "$final_path/VERSION")" != 1.2.2 ]] \
|
||||
&& ynh_die --message "It looks like that you have an old Garradin installed. You need to first upgrade your Garradin instance (id: $garradin_migrate_id) and after to migrate to Paheko."
|
||||
|
||||
ynh_handle_app_migration --migration_id=garradin --migration_list=garradin_migrations
|
||||
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
final_path="/var/www/$app"
|
||||
|
||||
# Replace the user
|
||||
ynh_system_user_delete --username=$old_app
|
||||
ynh_system_user_create --username=$app || \
|
||||
ynh_die --message "Unable to create $app system account"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -184,19 +189,19 @@ ynh_systemd_action --service_name=nginx --action=reload
|
|||
#=================================================
|
||||
|
||||
if [[ $migration_process -eq 1 ]]; then
|
||||
echo "Garradin has been successfully migrated to Paheko! \
|
||||
A last scheduled operation will run in a couple of minutes to finish the \
|
||||
migration in YunoHost side. Do not proceed any application operation while \
|
||||
you don't see Garradin as installed." >&2
|
||||
echo "Garradin has been successfully migrated to Paheko! \
|
||||
A last scheduled operation will run in a couple of minutes to finish the \
|
||||
migration in YunoHost side. Do not proceed any application operation while \
|
||||
you don't see Garradin as installed." >&2
|
||||
|
||||
# Execute a post migration script after the end of this upgrade.
|
||||
# Mainly for some cleaning
|
||||
script_post_migration=garradin_post_migration.sh
|
||||
ynh_replace_string --match_string __OLD_APP__ --replace_string "$old_app" --target_file ../conf/$script_post_migration
|
||||
ynh_replace_string --match_string __NEW_APP__ --replace_string "$app" --target_file ../conf/$script_post_migration
|
||||
cp ../conf/$script_post_migration /tmp
|
||||
chmod +x /tmp/$script_post_migration
|
||||
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes)
|
||||
# Execute a post migration script after the end of this upgrade.
|
||||
# Mainly for some cleaning
|
||||
script_post_migration=garradin_post_migration.sh
|
||||
ynh_replace_string --match_string __OLD_APP__ --replace_string "$old_app" --target_file ../conf/$script_post_migration
|
||||
ynh_replace_string --match_string __NEW_APP__ --replace_string "$app" --target_file ../conf/$script_post_migration
|
||||
cp ../conf/$script_post_migration /tmp
|
||||
chmod +x /tmp/$script_post_migration
|
||||
(cd /tmp; echo "/tmp/$script_post_migration > /tmp/$script_post_migration.log 2>&1" | at now + 2 minutes)
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue