mirror of https://github.com/lukechilds/umbrel.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
943 B
42 lines
943 B
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)"
|
|
MAX_BACKUP_INTERVAL_IN_HOURS="12"
|
|
|
|
check_if_not_already_running() {
|
|
if ps ax | grep $0 | grep -v $$ | grep bash | grep -v grep
|
|
then
|
|
echo "decoy trigger is already running"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_dependencies () {
|
|
for cmd in "$@"; do
|
|
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
echo "This script requires \"${cmd}\" to be installed"
|
|
exit 1
|
|
fi
|
|
done
|
|
}
|
|
|
|
check_if_not_already_running
|
|
|
|
check_dependencies shuf
|
|
|
|
main () {
|
|
while true; do
|
|
minutes_in_seconds="60"
|
|
hours_in_seconds="$((60 * ${minutes_in_seconds}))"
|
|
max_interval="$((${MAX_BACKUP_INTERVAL_IN_HOURS} * ${hours_in_seconds}))"
|
|
delay="$(shuf -i 0-${max_interval} -n 1)"
|
|
echo "Sleeping for ${delay} seconds..."
|
|
sleep $delay
|
|
echo "Triggering decoy backup..."
|
|
touch "${UMBREL_ROOT}/events/signals/backup"
|
|
done
|
|
}
|
|
|
|
main
|
|
|