diff --git a/scripts/install b/scripts/install index 034ad86..39b4def 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,17 @@ language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_script_progression --message="Validating installation parameters..." --weight=1 + +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" + +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url + #================================================= # STORE SETTINGS FROM MANIFEST #================================================= diff --git a/scripts/remove b/scripts/remove index acb2152..e744c92 100644 --- a/scripts/remove +++ b/scripts/remove @@ -16,26 +16,27 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME -# Retrieve arguments -domain=$(ynh_app_setting_get "$app" domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +ynh_script_progression --message="Removing app main directory..." --time --weight=3 -# Remove sources and configuration -ynh_secure_remove --file="/var/www/${app}" +# Remove the app directory securely +ynh_secure_remove --file=$final_path #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 -ynh_secure_remove --file="/etc/nginx/conf.d/${domain}.d/${app}.conf" +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last - +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 35aa320..fcbed7f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,16 +19,50 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -# Retrieve old app settings app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -# Restore sources & data -cp -a ./sources "/var/www/${app}" +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Restore Nginx and YunoHost parameters -cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=2 -# Reload services -service nginx reload +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=4 + +ynh_restore_file --origin_path=$final_path + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 40f8185..31dfa68 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,7 +14,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -58,7 +58,7 @@ sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -66,5 +66,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last - +ynh_script_progression --message="Upgrade of $app completed" --last