]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Avoid globally changing to queue directory
authorMartin Schwenke <mschwenke@ddn.com>
Wed, 8 May 2024 04:44:13 +0000 (14:44 +1000)
committerVolker Lendecke <vl@samba.org>
Thu, 30 May 2024 11:42:30 +0000 (11:42 +0000)
Add new variables statd_callout_state_dir and statd_callout_queue_dir
- the latter is for files queued by add-client/del-client.

Use $statd_callout_queue_dir to avoid a global cd to the queue
directory near the top of the script.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
ctdb/config/statd-callout

index 3f26fdfbfadc4bd472c6242ef0fc0f503a227129..375a22af26f47125d4c6e85be5893c2b5d8a1223 100755 (executable)
@@ -52,12 +52,13 @@ ctdb_setup_state_dir "service" "nfs"
 
 # script_state_dir set by ctdb_setup_state_dir()
 # shellcheck disable=SC2154
-d="${script_state_dir}/statd-callout"
+statd_callout_state_dir="${script_state_dir}/statd-callout"
 
 statd_callout_db="ctdb.tdb"
+statd_callout_queue_dir="${statd_callout_state_dir}/queue"
 
-mkdir -p "$d" || die "Failed to create directory \"${d}\""
-cd "$d" || die "Failed to change directory to \"${d}\""
+mkdir -p "$statd_callout_queue_dir" ||
+       die "Failed to create directory \"${statd_callout_queue_dir}\""
 
 pnn=$(ctdb_get_pnn)
 
@@ -142,7 +143,8 @@ add-client)
                while IFS="|" read -r x sip node x; do
                        [ "$node" = "$pnn" ] || continue # not us
                        key="statd-state@${sip}@${cip}"
-                       echo "\"${key}\" \"${date}\"" >"$key"
+                       file="${statd_callout_queue_dir}/${key}"
+                       echo "\"${key}\" \"${date}\"" >"$file"
                done
        ;;
 
@@ -157,11 +159,14 @@ del-client)
                while IFS="|" read -r x sip node x; do
                        [ "$node" = "$pnn" ] || continue # not us
                        key="statd-state@${sip}@${cip}"
-                       echo "\"${key}\" \"\"" >"$key"
+                       file="${statd_callout_queue_dir}/${key}"
+                       echo "\"${key}\" \"\"" >"$file"
                done
        ;;
 
 update)
+       cd "$statd_callout_queue_dir" ||
+               die "Failed to change directory to \"${statd_callout_queue_dir}\""
        files=$(echo statd-state@*)
        if [ "$files" = "statd-state@*" ]; then
                # No files!
@@ -265,7 +270,7 @@ notify)
        echo "$ctdb_all_ips" |
                awk -v pnn="$pnn" 'pnn != $2 { print $1 }' |
                while read -r sip; do
-                       rm -f "statd-state@${sip}@"*
+                       rm -f "${statd_callout_queue_dir}/statd-state@${sip}@"*
                done
        ;;
 esac