32 lines
463 B
Bash
32 lines
463 B
Bash
|
#!/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
|
||
|
|