
retry() {
    local N=$1; shift
    local t=$2; shift
    for i in $(seq 1 $N); do
        "$@" && return 0 || sleep $t
    done
    return 1
}

stow_nextcloud() {
    # Nextcloud
    if [ ! -d "$HOME/nextcloud/local_configs" ]; then
        echo "Fehler: Benötige $HOME/nextcloud/local_configs" >&2
        exit 1
    fi
    stow --dir=$HOME/nextcloud/local_configs --target=$HOME default
}

nextcloud &

retry 90 10 stow_nextcloud

