From 93aa4564d864f02987eebd1798e8d57ed6faa04f Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 9 May 2022 18:22:10 +0200 Subject: [PATCH 1/4] server.toml should always be at the beginning of config.toml --- conf/systemd.service | 3 ++- scripts/install | 6 +++--- scripts/upgrade | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index ff44d3b..e73f58a 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,8 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ ExecStartPre=-/bin/bash -c 'chown -R __APP__:__APP__ /etc/__APP__/' -ExecStartPre=-/bin/bash -c 'cat /etc/__APP__/config.d/*.toml > /etc/__APP__/config.toml' +ExecStartPre=-/bin/bash -c 'cp /etc/__APP__/config.d/server.toml.head /etc/__APP__/config.toml' +ExecStartPre=-/bin/bash -c 'cat /etc/__APP__/config.d/*.toml >> /etc/__APP__/config.toml' ExecStart=__FINALPATH__/live/__APP__ /etc/__APP__/config.toml StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/scripts/install b/scripts/install index 754991d..6dfd70f 100755 --- a/scripts/install +++ b/scripts/install @@ -118,10 +118,10 @@ chmod 750 "/etc/$app" chmod -R o-rwx "/etc/$app" chown -R "$app":"$app" "/etc/$app" -ynh_add_config --template="../conf/server.toml" --destination="/etc/$app/config.d/server.toml" +ynh_add_config --template="server.toml" --destination="/etc/$app/config.d/server.toml.head" -chmod 400 "/etc/$app/config.d/server.toml" -chown "$app":"$app" "/etc/$app/config.d/server.toml" +chmod 400 "/etc/$app/config.d/server.toml.head" +chown "$app":"$app" "/etc/$app/config.d/server.toml.head" #================================================= # SETUP SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 503e60f..de647c5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -129,10 +129,10 @@ chmod 750 "/etc/$app" chmod -R o-rwx "/etc/$app" chown -R "$app":"$app" "/etc/$app" -ynh_add_config --template="../conf/server.toml" --destination="/etc/$app/config.d/server.toml" +ynh_add_config --template="server.toml" --destination="/etc/$app/config.d/server.toml.head" -chmod 400 "/etc/$app/config.d/server.toml" -chown "$app":"$app" "/etc/$app/config.d/server.toml" +chmod 400 "/etc/$app/config.d/server.toml.head" +chown "$app":"$app" "/etc/$app/config.d/server.toml.head" #================================================= # SETUP SYSTEMD From 099c3fc95d32899713dfb19d3c99a6cb9a3555df Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 9 May 2022 20:01:43 +0200 Subject: [PATCH 2/4] remove the old server.toml on upgrade --- scripts/upgrade | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index de647c5..c3b9f01 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,6 +53,12 @@ ynh_systemd_action --service_name="$app" --action="stop" --line_match="Stopped" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." +# Upgrade from <=0.6.6~ynh1: +if ynh_compare_current_package_version --comparison le --version 0.6.6~ynh1 +then + rm /etc/"$app"/config.d/server.toml +fi + #================================================= # CREATE DEDICATED USER #================================================= From a70c6f53288aa55e564746db5d20cc7376442093 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 9 May 2022 23:46:16 +0200 Subject: [PATCH 3/4] remove the stored checksum before deleting server.toml --- scripts/upgrade | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c3b9f01..07369a7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,7 +56,8 @@ ynh_script_progression --message="Ensuring downward compatibility..." # Upgrade from <=0.6.6~ynh1: if ynh_compare_current_package_version --comparison le --version 0.6.6~ynh1 then - rm /etc/"$app"/config.d/server.toml + ynh_delete_file_checksum --file=/etc/"$app"/config.d/server.toml + ynh_secure_remove --file=/etc/"$app"/config.d/server.toml fi #================================================= From bd92d107a23c7936d18c3d8d747623d0ea17c2ec Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 9 May 2022 23:59:53 +0200 Subject: [PATCH 4/4] Fix upgrade --- scripts/upgrade | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 07369a7..a5e996b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,11 +53,12 @@ ynh_systemd_action --service_name="$app" --action="stop" --line_match="Stopped" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# Upgrade from <=0.6.6~ynh1: -if ynh_compare_current_package_version --comparison le --version 0.6.6~ynh1 +# Change to head file +if [ -f "/etc/$app/config.d/server.toml" ] then - ynh_delete_file_checksum --file=/etc/"$app"/config.d/server.toml - ynh_secure_remove --file=/etc/"$app"/config.d/server.toml + ynh_delete_file_checksum --file="/etc/$app/config.d/server.toml" + mv "/etc/$app/config.d/server.toml" "/etc/$app/config.d/server.toml.head" + ynh_store_file_checksum --file="/etc/$app/config.d/server.toml.head" fi #=================================================