--- vif-common.sh-orig 2007-03-05 21:51:53.000000000 +0000 +++ vif-common.sh 2007-03-06 13:51:27.000000000 +0000 @@ -35,6 +35,19 @@ add | remove) exit 0 ;; + online) + if [ -d /etc/xen/domU-up.d/ ]; then + name=`xenstore-read ${XENBUS_PATH}/domain` + runDirectory /etc/xen/domU-up.d/ "${name}" + fi + ;; + offline) + if [ -d /etc/xen/domU-down.d/ ]; then + name=`xenstore-read ${XENBUS_PATH}/domain` + runDirectory /etc/xen/domU-down.d/ "${name}" + + fi + ;; esac --- xen-script-common.sh-orig 2007-03-06 13:46:42.000000000 +0000 +++ xen-script-common.sh 2007-03-06 13:51:44.000000000 +0000 @@ -42,3 +42,25 @@ fi done } + + +# +# Run each executable script in the named directory, +# passing them any arguments specified. +# +runDirectory() +{ + dir=$1 + shift + args="$*" + + if [ -d $dir ]; then + for i in $dir/* ; do + # regular files only which are executable + if ( test -f $i -a -x $i ); then + $i ${args} + fi + done + fi +} +