Lets only sleep if we are not allready running

This commit is contained in:
Micke Nordin 2025-02-26 12:09:59 +01:00
parent 1654186ddc
commit 800b2c4afc
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257

View file

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
# We sleep a deterministic amount of time, which will be between 0 an 128 m and allways the same within
# a specific host, but will differ between hosts
sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk '{print $1}') / 2))m
# Only run if this is the only instance of this script running # Only run if this is the only instance of this script running
# note: since this script forks to run pgrep, we need -eq 2 here # note: since this script forks to run pgrep, we need -eq 2 here
if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then if [[ $(pgrep -f "${0}" | wc -l) -eq 2 ]]; then
# We sleep a deterministic amount of time, which will be between 0 an 128 m and allways the same within
# a specific host, but will differ between hosts
sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk '{print $1}') / 2))m
for container in $(get_containers); do for container in $(get_containers); do
for id in $(nocc "${container}" files_external:list --all --output json | jq '.[].mount_id' | jq .); do for id in $(nocc "${container}" files_external:list --all --output json | jq '.[].mount_id' | jq .); do
nocc "${container}" files_external:scan "${id}" nocc "${container}" files_external:scan "${id}"