From: Steve Kemp Subject: [PATCH] add domain creation/shutdown script execution support. Date: Tue, 6 Mar 2007 13:56:28 +0000 Message-ID: <20070306135628.GA14559@steve.org.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0893177760==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============0893177760== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CdrF4e02JqNVZeln" Content-Disposition: inline --CdrF4e02JqNVZeln Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This patch allows shell scripts / commands to be executed upon either of the following events: * Domain creation. * Domain shutdown. Scripts are executed in sorted order from two directories, which if not present will disable the behavior: * /etc/xen/domU-up.d/ * /etc/xen/domU-down.d/ Signed-off-by: Steve Kemp Steve --=20 http://www.steve.org.uk/ --M9NhX3UHpAaciwkO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="01-add-script-support.diff" Content-Transfer-Encoding: quoted-printable --- 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=3D`xenstore-read ${XENBUS_PATH}/domain` + runDirectory /etc/xen/domU-up.d/ "${name}" + fi + ;; + offline) + if [ -d /etc/xen/domU-down.d/ ]; then + name=3D`xenstore-read ${XENBUS_PATH}/domain` + runDirectory /etc/xen/domU-down.d/ "${name}" + + fi + ;; esac =20 =20 --- 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=3D$1 + shift + args=3D"$*" + + 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 +} + --M9NhX3UHpAaciwkO-- --CdrF4e02JqNVZeln Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFF7XMMwM/Gs81MDZ0RAlBtAKDXiBXzFXW1GGglPhkBWo1rsbaQpQCgrg9Y iAqTmQHa2vGrvDz//vD9J7k= =r3gF -----END PGP SIGNATURE----- --CdrF4e02JqNVZeln-- --===============0893177760== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0893177760==--