From 0ad65c1ca3a8576b24e7aea185143cf9e8d914fa Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 4 Jun 2020 05:36:19 +0200 Subject: [PATCH] adjust syntax for new examples_ynh --- check_process | 20 +++++++++++++------- scripts/change_url | 4 ++-- scripts/install | 13 ++++++------- scripts/remove | 12 +----------- scripts/restore | 12 ++---------- scripts/upgrade | 15 +++++++-------- 6 files changed, 31 insertions(+), 45 deletions(-) diff --git a/check_process b/check_process index 740aae0..8e0b5c4 100644 --- a/check_process +++ b/check_process @@ -2,7 +2,7 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - path="/cesium" (PATH) + path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 @@ -14,10 +14,16 @@ upgrade=1 backup_restore=1 multi_instance=0 - wrong_user=0 - wrong_path=1 - incorrect_path=1 - corrupt_source=0 - fail_download_source=0 port_already_use=0 - final_path_already_use=0 + change_url=1 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=na + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 \ No newline at end of file diff --git a/scripts/change_url b/scripts/change_url index f945988..776fce8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,7 +23,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -48,7 +48,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf diff --git a/scripts/install b/scripts/install index 0a0401a..132e32d 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --time --weight=1 +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -56,7 +56,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --time --weight=1 +ynh_script_progression --message="Setting up source files..." # Retrieve sources and install them ynh_app_setting_set --app=$app --key=final_path --value=$final_path @@ -76,7 +76,7 @@ ynh_app_setting_delete --app=$app --key=skipped_uris #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 +ynh_script_progression --message="Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config @@ -91,14 +91,13 @@ fi #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 - +ynh_script_progression --message="Configuring permissions..." # If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# activate read-only + ynh_permission_update --permission "main" --add "visitors" + # activate read-only ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" fi diff --git a/scripts/remove b/scripts/remove index d1e1303..99c0aa0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,7 +22,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -35,16 +35,6 @@ ynh_script_progression --message="Removing nginx web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/restore b/scripts/restore index dee9974..5edab66 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,7 +34,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -52,18 +52,10 @@ 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..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 91bb400..e8d497a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,7 +38,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -58,7 +58,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -87,7 +87,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -97,7 +97,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_add_nginx_config @@ -116,14 +116,13 @@ chown -R www-data: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 - +ynh_script_progression --message="Configuring permissions..." # If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# activate read-only + ynh_permission_update --permission "main" --add "visitors" + # activate read-only ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" fi