mirror of
https://github.com/YunoHost-Apps/teampass_ynh.git
synced 2024-09-03 20:26:37 +02:00
Update restore
This commit is contained in:
parent
5be8eaa1f1
commit
b29118eaca
1 changed files with 35 additions and 23 deletions
|
@ -22,20 +22,21 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get $app path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get $app db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
ynh_webpath_available $domain $path_url \
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die "There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
|
@ -48,28 +49,33 @@ ynh_maintenance_mode_ON
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE OF THE NGINX CONFIGURATION
|
# RESTORE OF THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE OF THE MAIN DIR OF THE APP
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE OF THE SQL BDD
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE OF THE DEDICATED USER
|
# RECREATE OF THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
||||||
|
|
||||||
ynh_system_user_create $app # Recreate the dedicated user, if not exist
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE MYSQL DATABASE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
|
@ -126,3 +132,9 @@ ynh_maintenance_mode_OFF
|
||||||
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/teampass_ynh"
|
message="If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/teampass_ynh"
|
||||||
|
|
||||||
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --last
|
||||||
|
|
Loading…
Add table
Reference in a new issue