From 06cb97a8c80ca14d1e58affed77d801004fe7e3e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 12 Mar 2021 16:27:44 +0100 Subject: [PATCH 1/4] It makes no sense to chown before curl ... --- scripts/install | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/install b/scripts/install index 5978825..c229870 100755 --- a/scripts/install +++ b/scripts/install @@ -216,9 +216,6 @@ ynh_add_systemd_config ### so we're going to use curl to automatically fill the fields and submit the ### forms. -# Set right permissions for curl install -chown -R $app: $final_path - # Set the app as temporarily public for curl call ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 # Making the app public for curl From bce44732999b1ae832eb3aa319dfaad47669078e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 12 Mar 2021 16:30:54 +0100 Subject: [PATCH 2/4] There's no need to run ssowatconf + nginx reload after editing perms ..? --- scripts/install | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/install b/scripts/install index c229870..22ee463 100755 --- a/scripts/install +++ b/scripts/install @@ -220,11 +220,6 @@ ynh_add_systemd_config ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 # Making the app public for curl ynh_permission_update --permission="main" --add="visitors" -# Reload SSOwat config -yunohost app ssowatconf - -# Reload NGINX -ynh_systemd_action --service_name=nginx --action=reload # Installation with curl ynh_script_progression --message="Finalizing installation..." --time --weight=1 From b7b0e172a5a34dd31b32fd115123588a60d8c34b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 12 Mar 2021 16:41:18 +0100 Subject: [PATCH 3/4] Recommend the use of ynh_add_config --- scripts/install | 33 +++++++++++++++++++-------------- scripts/upgrade | 19 ++++++++++++------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/scripts/install b/scripts/install index 22ee463..a7b45ed 100755 --- a/scripts/install +++ b/scripts/install @@ -229,24 +229,29 @@ ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" ynh_permission_update --permission="main" --remove="visitors" #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -### `ynh_replace_string` is used to replace a string in a file. -### (It's compatible with sed regular expressions syntax) +### You can add specific configuration files. +### +### Typically, put your template conf file in ../conf/your_config_file +### The template may contain strings such as __FOO__ or __FOO_BAR__, +### which will automatically be replaced by the values of $foo and $foo_bar +### +### ynh_add_config will also keep track of the config file's checksum, +### which later during upgrade may allow to automatically backup the config file +### if it's found that the file was manually modified +### +### Check the documentation of `ynh_add_config` for more info. -ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" +ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### `ynh_store_file_checksum` is used to store the checksum of a file. -### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, -### you can make a backup of this file before modifying it again if the admin had modified it. - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/CONFIG_FILE" +### For more complex cases where you want to replace stuff using regexes, +### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### When doing so, you also need to manually call ynh_store_file_checksum +### +### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" +### ynh_store_file_checksum --file="$final_path/some_config_file" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index fff0363..a749b70 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -159,17 +159,22 @@ ynh_script_progression --message="Upgrading systemd configuration..." --time --w ynh_add_systemd_config #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" +### Same as during install +### +### The file will automatically be backed-up if it's found to be manually modified (because +### ynh_add_config keeps track of the file's checksum) -ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" +ynh_add_config --template="some_config_file" --destination="$final_path/some_config_file" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/CONFIG_FILE" +### For more complex cases where you want to replace stuff using regexes, +### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### When doing so, you also need to manually call ynh_store_file_checksum +### +### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" +### ynh_store_file_checksum --file="$final_path/some_config_file" #================================================= # GENERIC FINALIZATION From 1327d3b9c8dae287313c43764617aa1007bf7311 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 12 Mar 2021 16:49:35 +0100 Subject: [PATCH 4/4] Add a small note about extra permissions --- scripts/install | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index a7b45ed..9ae52c7 100755 --- a/scripts/install +++ b/scripts/install @@ -287,7 +287,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 -### `yunohost service add` integrates a service in YunoHost. It then gets +### `yunohost service add` integrates a service in YunoHost. It then gets ### displayed in the admin interface and through the others `yunohost service` commands. ### (N.B.: this line only makes sense if the app adds a service to the system!) ### If you're not using these lines: @@ -351,6 +351,9 @@ then ynh_permission_update --permission="main" --add="visitors" fi +### N.B. : the following extra permissions only make sense if your app +### does have for example an admin interface or an api. + # Only the admin can access the admin panel of the app (if the app has an admin panel) ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin