Skip to content

Instantly share code, notes, and snippets.

@h0tw1r3
Created October 7, 2018 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h0tw1r3/1cc1c89dd20dd9265a8154945090698f to your computer and use it in GitHub Desktop.
Save h0tw1r3/1cc1c89dd20dd9265a8154945090698f to your computer and use it in GitHub Desktop.
hooks.d for libvirt
#!/bin/bash
# Copy or link this script to /etc/libvirt/hooks/{network,qemu,daemon,lxc}
TYPE=$(basename $0)
HOOKS_PATH="/etc/libvirt/hooks.d/${TYPE}/${1}"
[ ! -e "${HOOKS_PATH}" ] && exit 0
if [ -x "${HOOKS_PATH}/${2}/${3}" ] ; then
exec "${HOOKS_PATH}/${2}/${3}" "$@" <&0
elif [ -x "${HOOKS_PATH}/${2}" ] ; then
exec "${HOOKS_PATH}/${2}" "$@" <&0
elif [ -x "${HOOKS_PATH}" ] ; then
exec "${HOOKS_PATH}" "$@" <&0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment