#!/bin/bash
#
# Univention Configuration Registry
#  sleeps for a random time
#
# SPDX-FileCopyrightText: 2004-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

if [ $# -lt 2 ]
then
	echo
	echo 'use jitter <seconds> <command> [<command-options>]'
	echo
	echo 'sleeps for random time between 0 and <seconds> before exec of <command>'
	echo 'with given <command-options>'
	echo
	exit 2
fi >&2

sleep "$(( RANDOM % $1 ))"

shift
exec "$@"
