From ae5845526a964e0ab8161acf74b060f733191c5e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 10 May 2019 16:34:57 +0200 Subject: Apply example_ynh --- scripts/change_url | 68 ++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 38 deletions(-) (limited to 'scripts/change_url') diff --git a/scripts/change_url b/scripts/change_url index e87b369..784aa40 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,24 +24,16 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --time --weight=1 # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application -#db_name=$(ynh_app_setting_get "$app" db_name) -#db_pwd=$(ynh_app_setting_get $app db_pwd) -admin_mail=$(ynh_app_setting_get $app admin_mail) - -#================================================= -# CHECK THE SYNTAX OF THE PATHS -#================================================= - -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +admin_mail=$(ynh_app_setting_get --app=$app --key=admin_mail) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -61,10 +53,19 @@ fi #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped" +ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" +ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped" + #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -72,7 +73,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -84,49 +85,40 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= # SPECIFIC MODIFICATIONS -#================================================= -# STOP MASTODON SERVICES -#================================================= -ynh_print_info "Stopping Mastodon services..." - -ynh_systemd_action --action=stop --service_name=${app}-web --line_match="Stopped" --log_path=systemd -ynh_systemd_action --action=stop --service_name=${app}-sidekiq --line_match="Stopped" --log_path=systemd -ynh_systemd_action --action=stop --service_name=${app}-streaming --line_match="Stopped" --log_path=systemd - #================================================= # CHANGE CONFIGURATION #================================================= -ynh_replace_string "LOCAL_DOMAIN=.*" "LOCAL_DOMAIN=${domain}" "${final_path}/live/.env.production" +ynh_replace_string --match_string="LOCAL_DOMAIN=.*" --replace_string="LOCAL_DOMAIN=${domain}" --target_file="${final_path}/live/.env.production" #================================================= -# START MASTODON SERVICES +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE #================================================= -ynh_print_info "Starting Mastodon services..." +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 -ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd -ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd -ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd +ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" +ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" +ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening" -#================================================= -# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" --time --last -- cgit v1.2.3-70-g09d2