From 17ebeab5ac9638c953e117614eb088cca974b67a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Oct 2020 21:14:35 +0200 Subject: [PATCH] Apply last example_ynh --- README.md | 10 +++---- check_process | 7 +++++ issue_template.md | 55 +++++++++++++++++++++++++++++++++++++ scripts/backup | 35 +++++++----------------- scripts/change_url | 20 +++++++------- scripts/install | 36 ++++++++++++------------ scripts/remove | 22 +++++++-------- scripts/restore | 25 ++++++++--------- scripts/upgrade | 68 ++++++++++++++++++++++++++-------------------- 9 files changed, 164 insertions(+), 114 deletions(-) create mode 100644 issue_template.md diff --git a/README.md b/README.md index 47fcb66..f56d9fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WriteFreely app for Yunohost -[![Integration level](https://dash.yunohost.org/integration/writefreely.svg)](https://dash.yunohost.org/appci/app/writefreely) +[![Integration level](https://dash.yunohost.org/integration/writefreely.svg)](https://dash.yunohost.org/appci/app/writefreely) ![](https://ci-apps.yunohost.org/ci/badges/writefreely.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/writefreely.maintain.svg) [![Install WriteFreely with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=writefreely) > *This package allow you to install WriteFreely quickly and simply on a YunoHost server. @@ -47,7 +47,7 @@ If User Mode is configured Multiple users, the app be used by multiple users #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/writefreely/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/writefreely/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/writefreely%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/writefreely/) ## Limitations @@ -58,15 +58,15 @@ If User Mode is configured Multiple users, the app be used by multiple users * Report a bug: https://github.com/YunoHost-Apps/writefreely_ynh/issues * App website: https://writefreely.org/ - * GitHub website: https://github.com/writeas/writefreely + * Upstream app repository: https://github.com/writeas/writefreely * YunoHost website: https://yunohost.org/ --- -Developers info +Developer info ---------------- -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/writefreely_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/writefreely_ynh/tree/testing). To try the testing branch, please proceed like that. ``` diff --git a/check_process b/check_process index 7ef7279..fbfec3f 100644 --- a/check_process +++ b/check_process @@ -29,3 +29,10 @@ ;;; Options Email=yalh@yahoo.com Notification=all +;;; Upgrade options + ; commit=093ec18f9f5282e1a137c0ac5444a414ee2b83bc + name=0.8.1 + ; commit=45584b220e911c573643cb1e213e75fc42547818 + name=0.11.2 + + diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..ed9d110 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Make sure you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *In doubt, ask here and we will figure it out together.* +3. *Delete these italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install writefreely + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/scripts/backup b/scripts/backup index f359c68..63ac358 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -33,28 +32,30 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Stopping a systemd service..." - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Write Freely" +ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= @@ -62,22 +63,6 @@ ynh_print_info --message="Backing up the MySQL database..." ynh_mysql_dump_db --database="$db_name" > db.sql -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP SYSTEMD -#================================================= -ynh_print_info --message="Backing up systemd configuration..." - -ynh_backup --src_path="/etc/systemd/system/$app.service" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index a6edbb8..f96d983 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -25,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +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) @@ -38,7 +37,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -73,14 +72,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Write Freely" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -111,7 +110,7 @@ fi #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." ynh_backup_if_checksum_is_different --file="$final_path/config.ini" ynh_replace_string --match_string="host =.*" --replace_string="host = https://$new_domain" --target_file="$final_path/config.ini" @@ -119,7 +118,7 @@ ynh_replace_string --match_string="host =.*" --replace_string="host #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_print_info --message="Storingthe config file checksum..." +ynh_script_progression --message="Storingthe config file checksum..." # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/config.ini" @@ -129,14 +128,15 @@ ynh_store_file_checksum --file="$final_path/config.ini" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -144,4 +144,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index ae5aeeb..b8f0e7c 100755 --- a/scripts/install +++ b/scripts/install @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,6 @@ 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="/" @@ -46,7 +44,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." # Check machine architecture, we don't support 32bit machines if [ $architecture = "i386" ] @@ -63,7 +61,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -76,7 +74,7 @@ ynh_app_setting_set --app=$app --key=single_user --value=$single_user #================================================= # FIND AND OPEN A PORT #================================================= -ynh_print_info --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." # Find an available port port=$(ynh_find_port --port=8095) @@ -85,7 +83,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_print_info --message="Creating a MySQL database..." +ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -95,7 +93,7 @@ ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -104,7 +102,7 @@ ynh_setup_source --dest_dir="$final_path" --source_id=$architecture #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -112,7 +110,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app --home_dir="$final_path" @@ -122,7 +120,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -130,7 +128,7 @@ ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." # setup application config cp "../conf/config.ini" "$final_path/config.ini" @@ -145,7 +143,7 @@ ynh_replace_string --match_string="__SINGLEUSER__" --replace_string="$single_use #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_print_info --message="Storing the config file checksum..." +ynh_script_progression --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$final_path/config.ini" @@ -153,7 +151,7 @@ ynh_store_file_checksum --file="$final_path/config.ini" #================================================= # MAKE SETUP #================================================= -ynh_print_info --message="Making setup..." +ynh_script_progression --message="Making setup..." chown -R "$app":"$app" "$final_path" @@ -168,7 +166,7 @@ popd #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R "$app":"$app" "$final_path" @@ -176,14 +174,14 @@ chown -R "$app":"$app" "$final_path" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for WriteFreely" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on" @@ -191,7 +189,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -203,7 +201,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -211,4 +209,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index e29b51a..29e310c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -27,19 +27,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # 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 then - ynh_print_info --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info --message="Stopping and removing the systemd service..." +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -47,7 +46,7 @@ ynh_remove_systemd_config #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info --message="Removing the MySQL database..." +ynh_script_progression --message="Removing the MySQL database..." # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name @@ -55,7 +54,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -63,7 +62,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -71,7 +70,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -79,11 +78,10 @@ ynh_remove_logrotate #================================================= # CLOSE A PORT #================================================= -ynh_print_info --message="Closing a port..." if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info --message="Closing port $port..." + ynh_script_progression --message="Closing port $port..." ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -92,7 +90,7 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -101,4 +99,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_print_info --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 5338b70..c084d99 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -37,7 +36,7 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info --message="Validating restoration parameters..." +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}" @@ -49,21 +48,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -71,7 +70,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS #================================================= -ynh_print_info --message="Restoring user rights..." +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R "$app":"$app" "$final_path" @@ -81,7 +80,7 @@ chown -R "$app":"$app" "$final_path" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_print_info --message="Restoring the MySQL database..." +ynh_script_progression --message="Restoring the MySQL database..." db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -90,7 +89,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service @@ -98,14 +97,14 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for WriteFreely" --log_type systemd #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on" @@ -114,7 +113,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -122,4 +121,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index b2fc906..3a7de24 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,14 +32,14 @@ architecture=$(ynh_detect_arch) #================================================= # CHECK VERSION #================================================= -ynh_print_info --message="Checking version..." +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -83,7 +83,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before upgrading (may take a while)..." +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 @@ -100,7 +100,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Write Freely" @@ -110,7 +110,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_print_info --message="Upgrading source files..." + 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" --source_id=$architecture @@ -119,7 +119,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -127,7 +127,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -137,7 +137,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # MAKE THE UPGRADE #================================================= -ynh_print_info --message="Making the upgrade..." +ynh_script_progression --message="Making the upgrade..." chown -R "$app":"$app" "$final_path" @@ -147,37 +147,52 @@ pushd $final_path sudo -u $app ./writefreely --migrate popd -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_print_info --message="Storing the config file checksum..." - -ynh_backup_if_checksum_is_different --file="$final_path/config.ini" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/config.ini" - #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= +ynh_script_progression --message="Storing the config file checksum..." + +ynh_backup_if_checksum_is_different --file="$final_path/config.ini" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$final_path/config.ini" + #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R "$app":"$app" "$final_path" +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description "$app daemon for WriteFreely" --log "/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on" + #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -186,17 +201,10 @@ then ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving on" - #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -204,4 +212,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed"