#!/bin/sh
set -eu

HOOKDIR=/etc/libvirt/hooks
BASENAME="${0##*/}"
PARTSDIR="$HOOKDIR/${BASENAME}.d"

if [ -d "$PARTSDIR" ]; then
  run-parts --verbose --exit-on-error --stdin \
    $(for arg in "$@"; do echo -- --arg="$arg"; done) \
    -- "$PARTSDIR"

else
  ME="$(realpath --no-symlinks "$0")"
  echo >&2 "$ME exists but no $PARTSDIR, so nothing to do!"

fi
