From 49d6dcebadaeddadad05d13db45cf2a919290566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 6 Dec 2023 11:24:08 +0100 Subject: [PATCH] Store file to settings file in a common variable --- scripts/_common.sh | 2 ++ scripts/backup | 2 +- scripts/change_url | 6 +++--- scripts/install | 6 +++--- scripts/restore | 4 ++-- scripts/upgrade | 6 +++--- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..ce07a20 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,8 @@ # COMMON VARIABLES #================================================= +SETTINGS_FILE="/etc/transmission-daemon/settings.json" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index a42bc4a..685d207 100644 --- a/scripts/backup +++ b/scripts/backup @@ -33,7 +33,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/transmission-daemon/settings.json" +ynh_backup --src_path="$SETTINGS_FILE" if [ -e /proc/sys/net/core/rmem_max ] then ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf" diff --git a/scripts/change_url b/scripts/change_url index 3e576c1..eea1d3c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,11 +31,11 @@ ynh_change_url_nginx_config # UPDATE TRANSMISSION CONFIGURATION #================================================= -ynh_backup_if_checksum_is_different --file="/etc/transmission-daemon/settings.json" +ynh_backup_if_checksum_is_different --file="$SETTINGS_FILE" -ynh_replace_string --match_string="rpc-url\": \"${old_path%/}/transmission/" --replace_string="rpc-url\": \"${new_path%/}/transmission/" --target_file="/etc/transmission-daemon/settings.json" +ynh_replace_string --match_string="rpc-url\": \"${old_path%/}/transmission/" --replace_string="rpc-url\": \"${new_path%/}/transmission/" --target_file="$SETTINGS_FILE" -ynh_store_file_checksum --file="/etc/transmission-daemon/settings.json" +ynh_store_file_checksum --file="$SETTINGS_FILE" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 0bd7254..93f79ba 100644 --- a/scripts/install +++ b/scripts/install @@ -51,10 +51,10 @@ else path_less="$path" fi -ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json" +ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE" -chmod 400 "/etc/transmission-daemon/settings.json" -chown debian-transmission:debian-transmission "/etc/transmission-daemon/settings.json" +chmod 400 "$SETTINGS_FILE" +chown debian-transmission:debian-transmission "$SETTINGS_FILE" if [ -e /proc/sys/net/core/rmem_max ] then diff --git a/scripts/restore b/scripts/restore index c7012e0..d14da4c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -37,8 +37,8 @@ ynh_script_progression --message="Restoring various files..." --weight=2 # Transmission has to be stopped before modifying its config ynh_systemd_action --service_name=transmission-daemon --action=stop -ynh_secure_remove --file=/etc/transmission-daemon/settings.json -ynh_restore_file --origin_path=/etc/transmission-daemon/settings.json +ynh_secure_remove --file="$SETTINGS_FILE" +ynh_restore_file --origin_path="$SETTINGS_FILE" if [ -e /proc/sys/net/core/rmem_max ] then diff --git a/scripts/upgrade b/scripts/upgrade index 5f9f922..17c5f47 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,10 +44,10 @@ else path_less="$path" fi -ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json" +ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE" -chmod 400 "/etc/transmission-daemon/settings.json" -chown debian-transmission:debian-transmission "/etc/transmission-daemon/settings.json" +chmod 400 "$SETTINGS_FILE" +chown debian-transmission:debian-transmission "$SETTINGS_FILE" if [ -e /proc/sys/net/core/rmem_max ] then