From 75151abf354067e85921aa0d99ce31b8fbdb5ca5 Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 29 Jun 2007 11:52:19 +0000 Subject: [PATCH] 2007-06-29 11:52:19 by steve Test that the Xen configuration file contains "valid" vif-script and network-script settings to aid beginners: http://www.debian-administration.org/articles/533#comment_2 --- bin/xen-create-image | 96 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index fbf9d6c..c5b0878 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -563,7 +563,7 @@ Install an X11 server, using VNC and XDM -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.158 2007-06-19 22:35:34 steve Exp $ + $Id: xen-create-image,v 1.159 2007-06-29 11:52:19 steve Exp $ =cut @@ -623,6 +623,8 @@ my $RELEASE = '3.5'; +testXenConfig(); +exit; @@ -976,10 +978,100 @@ EOF exit; } } + + + # + # Test the system has a valid (network-script) + (vif-script) setup. + # + testXenConfig(); + } + +=begin doc + + Test that the current Xen host has a valid network configuration, + this is designed to help newcomers to Xen. + +=end doc + +=cut + +sub testXenConfig +{ + # wierdness. + return if ( ! -d "/etc/xen" ); + + # + # Temporary hash. + # + my %cfg; + + # + # Read the configuration file. + # + open( CONFIG, "<", "/etc/xen/xend-config.sxp" ) + or die "Failed to read /etc/xen/xend-config.xsp: $!"; + while( ) + { + next if ( ! $_ || !length( $_ ) ); + + # vif + if ( $_ =~ /^\(vif-script ([^)]+)/ ) + { + $cfg{'vif-script'} = $1; + } + + # network + if ( $_ =~ /^\(network-script ([^)]+)/ ) + { + $cfg{'network-script'} = $1; + } + } + close( CONFIG ); + + if ( !defined( $cfg{'network-script'} ) || + !defined( $cfg{'vif-script'} ) ) + { + print <