ovhddns/periodic.sh

32 lines
463 B
Bash
Raw Permalink Normal View History

2023-02-21 20:45:50 +01:00
#!/bin/sh
pids=""
run_prog() {
"$@" &
pids="$! $pids"
}
trap_sig() {
printf '%s' "$pids" | while IFS= read -r pid; do
echo "pid=$pid"
# shellcheck disable=2086
kill -s $1 $pid
done
}
trap 'trap_sig TERM' TERM
# default to every 5 minutes
DELAY="${OVHDDNS_INTERVAL_SECONDS:-300}"
stdin_content="$(cat -)"
while :; do
echo "$stdin_content" | ovhddns "$@"
run_prog sleep "$DELAY"
wait $pids
pids=
done