From 3001da8c68616d5692857d2b6b0cfae1eca2ba75 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 5 Nov 2020 13:58:06 +0100 Subject: [PATCH] Fix --- README.md | 22 +++------- scripts/backup | 2 +- scripts/change_url | 107 +++++++++++++++++++++++++++++++++++++++++++++ scripts/install | 2 +- scripts/remove | 4 +- scripts/restore | 4 +- scripts/upgrade | 4 +- 7 files changed, 122 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index d60f156..5a20345 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# Chtickynotes for YunoHost +# ChtickyNotes for YunoHost [![Integration level](https://dash.yunohost.org/integration/chtickynotes.svg)](https://dash.yunohost.org/appci/app/chtickynotes) ![](https://ci-apps.yunohost.org/ci/badges/chtickynotes.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/chtickynotes.maintain.svg) -[![Install chtickynotes with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=chtickynotes) +[![Install ChtickyNotes with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=chtickynotes) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install chtickynotes quickly and simply on a YunoHost server. +> *This package allows you to install ChtickyNotes quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -chtickynotes_ynh core is based on [Post It All!](https://github.com/txusko/PostItAll). -chtickynotes_ynh is a "simple post-it" application. Its main features are: +ChtickyNotes core is based on [Post It All!](https://github.com/txusko/PostItAll). +ChtickyNotes is a "simple post-it" application. Its main features are: - notes movable and resizable - edit note by just typing on it (or CTRL-V to paste chunks of HTML) - menu on each note to change its color, and so on @@ -24,14 +24,6 @@ chtickynotes_ynh is a "simple post-it" application. Its main features are: ![](https://lh4.googleusercontent.com/-ATC-XA5iVsc/VM06cI3ClLI/AAAAAAAACHo/uBhDViaSBRg/s800/chtickynotes.gif) -## Demo - -* [Official demo](Link to a demo site for this app.) - -## Configuration - -How to configure this app: From an admin panel, a plain file with SSH, or any other way. - ## Documentation * Official documentation: Link to the official documentation of this app @@ -41,8 +33,8 @@ How to configure this app: From an admin panel, a plain file with SSH, or any ot #### Multi-user support -Are LDAP and HTTP auth supported? -Can the app be used by multiple users? +* Are LDAP and HTTP auth supported? +* Can the app be used by multiple users? #### Supported architectures diff --git a/scripts/backup b/scripts/backup index 48e8fb6..e9b4a77 100644 --- a/scripts/backup +++ b/scripts/backup @@ -46,4 +46,4 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for ChtickyNotes. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index e69de29..353e485 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -0,0 +1,107 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +# Stop script if errors +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --weight=1 + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up ChtickyNotes before changing its URL (may take a while)..." --weight=2 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=3 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=2 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for ChtickyNotes" --last diff --git a/scripts/install b/scripts/install index cde1675..9ff9fc3 100644 --- a/scripts/install +++ b/scripts/install @@ -88,4 +88,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of ChtickyNotes completed" --last diff --git a/scripts/remove b/scripts/remove index 6ddb24d..55b082a 100644 --- 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..." --weight=2 +ynh_script_progression --message="Removing ChtickyNotes main directory..." --weight=2 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -39,4 +39,4 @@ ynh_remove_nginx_config # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of ChtickyNotes completed" --last diff --git a/scripts/restore b/scripts/restore index bc45fee..38cd912 100644 --- a/scripts/restore +++ b/scripts/restore @@ -47,7 +47,7 @@ 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..." --weight=2 +ynh_script_progression --message="Restoring ChtickyNotes main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" @@ -78,4 +78,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for ChtickyNotes" --last diff --git a/scripts/upgrade b/scripts/upgrade index a6177aa..73862e1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +ynh_script_progression --message="Backing up ChtickyNotes before upgrading (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -87,4 +87,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of ChtickyNotes completed" --last