diff --git a/manifest.json b/manifest.json index fdbb369..b7e28d5 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "riot", "packaging_format": 1, "requirements": { - "yunohost": ">= 2.7.14" + "yunohost": ">= 3.5.2.2" }, "description": { "en": "A web client for matrix", diff --git a/scripts/_common.sh b/scripts/_common.sh index eada8cc..79d5072 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,11 +13,11 @@ final_path="/var/www/$app" config_riot() { cp ../conf/config.json $final_path/config.json - ynh_replace_string __DEFAULT_SERVER__ $default_home_server $final_path/config.json + ynh_replace_string --match_string __DEFAULT_SERVER__ --replace_string $default_home_server --target_file $final_path/config.json } install_source() { - ynh_setup_source $final_path/ + ynh_setup_source --dest_dir $final_path/ # if the default homeserver is external we dont add the sso support if [[ $(yunohost domain list | grep "$default_home_server") ]] diff --git a/scripts/backup b/scripts/backup index 09186fa..c63aaac 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,14 +19,17 @@ source ../settings/scripts/_common.sh #================================================= # Retrieve arguments -domain=$(ynh_app_setting_get $app domain) +ynh_script_progression --message="Loading installation settings..." +domain=$(ynh_app_setting_get --app $app --key domain) + +ynh_script_progression --message="Backing configuration..." # Copy Nginx config -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" # BACKUP THE PHP-FPM CONFIGURATION -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup --src_path "/etc/php5/fpm/pool.d/$app.conf" # Backup riot files -ynh_backup "/var/www/$app" - +ynh_script_progression --message="Backing up the main app directory..." +ynh_backup --src_path "/var/www/$app" diff --git a/scripts/change_url b/scripts/change_url index e233f5d..d041fb6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -15,23 +15,28 @@ source ./experimental_helper.sh source ./_common.sh # Retrive arguments +ynh_script_progression --message="Loading installation settings..." old_domain=$YNH_APP_OLD_DOMAIN -path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'}) +path_url=$(ynh_normalize_url_path --path_url ${YNH_APP_NEW_PATH:-'/'}) domain=$YNH_APP_NEW_DOMAIN #================================================= # STANDARD MODIFICATIONS #================================================= +ynh_script_progression --message="Updating configuration..." + # Update nginx config if [ "$old_domain" != "$domain" ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "/etc/nginx/conf.d/$old_domain.d/$app.conf" + ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf" mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf" # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" + ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf" fi ynh_add_nginx_config + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/experimental_helper.sh b/scripts/experimental_helper.sh index 9af5ee2..e69de29 100644 --- a/scripts/experimental_helper.sh +++ b/scripts/experimental_helper.sh @@ -1,10 +0,0 @@ -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} diff --git a/scripts/install b/scripts/install index 4f926c1..7b27b74 100644 --- a/scripts/install +++ b/scripts/install @@ -14,35 +14,40 @@ ynh_abort_if_errors source ./experimental_helper.sh source ./_common.sh +ynh_script_progression --message="Validating installation parameters..." + # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN -path_url=$(ynh_normalize_url_path $YNH_APP_ARG_PATH) +path_url=$(ynh_normalize_url_path --path_url $YNH_APP_ARG_PATH) is_public=$YNH_APP_ARG_IS_PUBLIC default_home_server=$YNH_APP_ARG_DEFAULT_HOME_SERVER -# Check domain/path availability -ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path." -ynh_webpath_register $app $domain $path_url +# Register (book) web path +ynh_webpath_register --app $app --domain $domain --path_url $path_url # Check Final Path availability -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message "This path already contains a folder" # Enregistre les infos dans la config YunoHost -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app default_home_server $default_home_server -ynh_app_setting_set $app final_path $final_path +ynh_script_progression --message="Storing installation settings..." +ynh_app_setting_set --app $app --key is_public --value $is_public +ynh_app_setting_set --app $app --key default_home_server --value $default_home_server +ynh_app_setting_set --app $app --key final_path --value $final_path #================================================= # STANDARD MODIFICATIONS #================================================= # Create a system user -ynh_system_user_create $app +ynh_script_progression --message="Configuring system user..." +ynh_system_user_create --username $app # Get source and install in source dir +ynh_script_progression --message="Installing sources files..." --weight=10 install_source # Create a dedicated php-fpm config +ynh_script_progression --message="Configuring application..." ynh_add_fpm_config # Update Riot config @@ -56,13 +61,15 @@ ynh_add_nginx_config #================================================= # Set final permission +ynh_script_progression --message="Protecting directory" set_permission +ynh_script_progression --message="Configuring permissions" if [ "$is_public" = "0" ]; then # Retire l'accès public - ynh_app_setting_delete $app skipped_uris + ynh_app_setting_delete --app $app --key skipped_uris else - ynh_app_setting_set $app unprotected_uris "/" + ynh_app_setting_set --app $app --key unprotected_uris --value "/" fi # Recharge la configuration Nginx diff --git a/scripts/remove b/scripts/remove index fb4fec3..73e52bf 100755 --- a/scripts/remove +++ b/scripts/remove @@ -16,16 +16,20 @@ source ./_common.sh #================================================= # Retrieve arguments -domain=$(ynh_app_setting_get $app domain) +ynh_script_progression --message="Loading installation settings..." +domain=$(ynh_app_setting_get --app $app --key domain) + +# Remove all files +ynh_script_progression --message="Removing app main directory..." --weight=4 +ynh_secure_remove --file="/var/www/$app" + +# Suppression de la configuration nginx +ynh_script_progression --message="Removing configuration..." +ynh_remove_nginx_config # Remove the dedicated php-fpm config ynh_remove_fpm_config -# Remove all files -ynh_secure_remove "/var/www/$app" - -# Suppression de la configuration nginx -ynh_remove_nginx_config - # Delete a system user -ynh_system_user_delete $app \ No newline at end of file +ynh_script_progression --message="Removing apps user..." +ynh_system_user_delete --username $app diff --git a/scripts/restore b/scripts/restore index 2817d89..c78c5d0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,20 +15,23 @@ source ../settings/scripts/experimental_helper.sh source ../settings/scripts/_common.sh # Retrieve arguments -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) +ynh_script_progression --message="Loading settings..." +domain=$(ynh_app_setting_get --app $app --key domain) +path_url=$(ynh_app_setting_get --app $app --key path) # Check domain/path availability -ynh_webpath_available $domain $path_url || ynh_die "$domain/$path_url is not available, please use an other domain or path." +ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path." #================================================= # STANDARD RESTORATION STEPS #================================================= # Create a system user -ynh_system_user_create $app +ynh_script_progression --message="Recreating the dedicated system user..." +ynh_system_user_create --username $app # Restore all config and data +ynh_script_progression --message="Restoring files..." --weight=10 ynh_restore #================================================= @@ -36,8 +39,10 @@ ynh_restore #================================================= # Set final permission +ynh_script_progression --message="Protecting directory..." set_permission # Reload nginx +ynh_script_progression --message="Reloading services..." systemctl reload nginx.service -systemctl reload php5-fpm \ No newline at end of file +systemctl reload php5-fpm diff --git a/scripts/upgrade b/scripts/upgrade index 0ec95fb..bd17998 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,27 +15,32 @@ source ./experimental_helper.sh source ./_common.sh # Retrieve arguments -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path)) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) -default_home_server=$(ynh_app_setting_get $app default_home_server) +ynh_script_progression --message="Loading installation settings..." +domain=$(ynh_app_setting_get --app $app --key domain) +path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path)) +is_public=$(ynh_app_setting_get --app $app --key is_public) +final_path=$(ynh_app_setting_get --app $app --key final_path) +default_home_server=$(ynh_app_setting_get --app $app --key default_home_server) #================================================= # MIGRATION FROM OLD VERSION #================================================= # Create a system user -grep "riot" "/etc/passwd" || ynh_system_user_create $app +ynh_script_progression --message="Migrating application..." --weight=1 +grep "riot" "/etc/passwd" || ynh_system_user_create --username $app #================================================= # STANDARD UPGRADE STEPS #================================================= # Get source and install in source dir -ynh_secure_remove $final_path/bundles +ynh_script_progression --message="Upgrading source files..." --weight=6 +ynh_secure_remove --file=$final_path/bundles install_source +ynh_script_progression --message="Configuring application..." + # Create a dedicated php-fpm config ynh_add_fpm_config @@ -50,6 +55,7 @@ ynh_add_nginx_config #================================================= # Set final permission +ynh_script_progression --message="Protecting directory..." set_permission # Recharge la configuration Nginx