backupninja/handlers/nap.in
Emil Breiner 0d8afeb807 Introduction of a new helper-handler pair named nap
The .nap file can be created to freeze the processing of the configurations for a (static) random interval. It is possible to specify the interval in seconds with a min and a max value and if it should be static.

Change-Id: I9523fd3645b1007fe7e24b6bd4ec18a104a07e05
2020-11-19 16:48:02 +01:00

26 lines
920 B
Plaintext

# nap.handler for processing the .nap files to freeze the processing of configurations
# in the configuration directory of backupninja temporary.
getconf nap_static_random_delay
getconf nap_interval_min
getconf nap_interval_max
# check for static random delay
if [ $nap_static_random_delay == "false" ]; then
# use perl rand if static random is set false
delay=$(perl -e "print int($nap_interval_min + rand($nap_interval_max - $nap_interval_min))")
else
# seed rand with machine-id, the substring 0,8 is needed so the integer value does not
# overflows the max integer value of perl on a 32 bit system. With this method entropy isn't
# a problem
delay=$(cat /etc/machine-id | perl -e "srand(hex(substr(<STDIN>,0,8))); \
print int($nap_interval_min + rand($nap_interval_max - $nap_interval_min))")
fi
echo "Holding processing of configurations for $delay seconds..."
perl -e "sleep $delay"