From 0e19cc61e66f5b4a186ec14b56a4cbbb93ede945 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 22 Feb 2020 18:44:18 +0100 Subject: [PATCH] Apply example_ynh --- scripts/backup | 1 + scripts/install | 11 +++++++++-- scripts/remove | 2 ++ scripts/restore | 7 +++++-- scripts/upgrade | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index a02cbca..b2b411f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting diff --git a/scripts/install b/scripts/install index c8c5765..7f0c450 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -23,6 +24,7 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url="/" @@ -63,7 +65,7 @@ ynh_app_setting_set --app=$app --key=ldap_password --value=$ldap_password #================================================= ynh_print_info --message="Configuring firewall..." -# Find a free port +# Find an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port @@ -135,6 +137,7 @@ ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_print_info --message="Modifying a config file..." config_file="$final_path/config.yml" cp -f ../conf/config.sample.yml $config_file @@ -146,6 +149,7 @@ ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --ta #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_print_info --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config_file" @@ -155,6 +159,7 @@ ynh_store_file_checksum --file="$config_file" #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions to app files chown -R "$app":"$app" "$final_path" @@ -162,14 +167,16 @@ chown -R "$app":"$app" "$final_path" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." -# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added yunohost service add $app --description "$app daemon for Wiki.js" --log_type systemd #================================================= # START SYSTEMD SERVICE #================================================= +ynh_print_info --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="HTTP Server:" #================================================= diff --git a/scripts/remove b/scripts/remove index 86f4b65..4750d42 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,6 +29,7 @@ ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= +ynh_print_info --message="Removing service integration in YunoHost..." # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null @@ -81,6 +82,7 @@ ynh_remove_nginx_config #================================================= # CLOSE A PORT #================================================= +ynh_print_info --message="Closing a port..." if yunohost firewall list | grep -q "\- $port$" then diff --git a/scripts/restore b/scripts/restore index 83ce0db..ef650cf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -12,7 +12,8 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE -#================================================= +#===ynh_print_info --message="Managing script failure..." +============================================== ynh_clean_setup () { ynh_clean_check_starting @@ -51,6 +52,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -72,6 +74,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS #================================================= +ynh_print_info --message="Restoring user rights..." # Restore permissions on app files chown -R "$app":"$app" "$final_path" @@ -84,7 +87,6 @@ chown -R "$app":"$app" "$final_path" ynh_print_info --message="Reinstalling dependencies..." # Define and install dependencies - ynh_install_nodejs --nodejs_version="10" ynh_install_app_dependencies $pkg_dependencies @@ -109,6 +111,7 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for Wiki.js" --log_type systemd diff --git a/scripts/upgrade b/scripts/upgrade index 47d5665..8e46b79 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,6 +32,7 @@ ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password) #================================================= # CHECK VERSION #================================================= +ynh_print_info --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed)