Compare commits
1 Commits
release-4.
...
debian-3.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aba8e1b411 |
23
Makefile
23
Makefile
@@ -12,9 +12,8 @@
|
|||||||
#
|
#
|
||||||
# Only used to build distribution tarballs.
|
# Only used to build distribution tarballs.
|
||||||
#
|
#
|
||||||
TMP ?= /tmp
|
|
||||||
DIST_PREFIX = ${TMP}
|
DIST_PREFIX = ${TMP}
|
||||||
VERSION = 4.1
|
VERSION = 3.9
|
||||||
BASE = xen-tools
|
BASE = xen-tools
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ clean:
|
|||||||
@find . -name '*.tmp' -exec rm \{\} \;
|
@find . -name '*.tmp' -exec rm \{\} \;
|
||||||
@find . -name 'tags' -exec rm \{\} \;
|
@find . -name 'tags' -exec rm \{\} \;
|
||||||
@find . -name '*.8.gz' -exec rm \{\} \;
|
@find . -name '*.8.gz' -exec rm \{\} \;
|
||||||
@if [ -d man ]; then rm -rf man ; fi
|
@find man -name '*.html' -exec rm \{\} \;
|
||||||
@if [ -e build-stamp ]; then rm -f build-stamp ; fi
|
@if [ -e build-stamp ]; then rm -f build-stamp ; fi
|
||||||
@if [ -e configure-stamp ]; then rm -f configure-stamp ; fi
|
@if [ -e configure-stamp ]; then rm -f configure-stamp ; fi
|
||||||
@if [ -d debian/xen-tools ]; then rm -rf ./debian/xen-tools; fi
|
@if [ -d debian/xen-tools ]; then rm -rf ./debian/xen-tools; fi
|
||||||
@@ -159,8 +158,6 @@ install-hooks:
|
|||||||
cp -R hooks/edgy/*-* ${prefix}/usr/lib/xen-tools/edgy.d/
|
cp -R hooks/edgy/*-* ${prefix}/usr/lib/xen-tools/edgy.d/
|
||||||
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d feisty.d
|
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d feisty.d
|
||||||
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d gutsy.d
|
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d gutsy.d
|
||||||
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d hardy.d
|
|
||||||
-cd ${prefix}/usr/lib/xen-tools/ && ln -s edgy.d intrepid.d
|
|
||||||
mkdir -p ${prefix}/usr/lib/xen-tools/dapper.d/
|
mkdir -p ${prefix}/usr/lib/xen-tools/dapper.d/
|
||||||
cp -R hooks/dapper/*-* ${prefix}/usr/lib/xen-tools/dapper.d/
|
cp -R hooks/dapper/*-* ${prefix}/usr/lib/xen-tools/dapper.d/
|
||||||
mkdir -p ${prefix}/usr/lib/xen-tools/edgy.d/
|
mkdir -p ${prefix}/usr/lib/xen-tools/edgy.d/
|
||||||
@@ -196,7 +193,6 @@ install: fixup-perms install-bin install-etc install-hooks install-libraries ins
|
|||||||
# Build our manpages via the `pod2man` command.
|
# Build our manpages via the `pod2man` command.
|
||||||
#
|
#
|
||||||
manpages:
|
manpages:
|
||||||
mkdir man
|
|
||||||
cd bin; for i in *-*; do pod2man --release=${VERSION} --official --section=8 $$i ../man/$$i.8; done
|
cd bin; for i in *-*; do pod2man --release=${VERSION} --official --section=8 $$i ../man/$$i.8; done
|
||||||
for i in man/*.8; do gzip --force -9 $$i; done
|
for i in man/*.8; do gzip --force -9 $$i; done
|
||||||
|
|
||||||
@@ -204,7 +200,7 @@ manpages:
|
|||||||
#
|
#
|
||||||
# Make a new release tarball, and make a GPG signature.
|
# Make a new release tarball, and make a GPG signature.
|
||||||
#
|
#
|
||||||
release: tidy fixup-perms update-version update-modules clean changelog
|
release: fixup-perms update-version update-modules clean changelog
|
||||||
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)
|
rm -rf $(DIST_PREFIX)/$(BASE)-$(VERSION)
|
||||||
rm -f $(DIST_PREFIX)/$(BASE)-$(VERSION).tar.gz
|
rm -f $(DIST_PREFIX)/$(BASE)-$(VERSION).tar.gz
|
||||||
cp -R . $(DIST_PREFIX)/$(BASE)-$(VERSION)
|
cp -R . $(DIST_PREFIX)/$(BASE)-$(VERSION)
|
||||||
@@ -232,17 +228,6 @@ test-verbose:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Run our main script(s) through perltidy
|
|
||||||
#
|
|
||||||
tidy:
|
|
||||||
if [ -x /usr/bin/perltidy ]; then \
|
|
||||||
for i in bin/*-*; do \
|
|
||||||
echo "tidying $$i"; \
|
|
||||||
perltidy $$i \
|
|
||||||
; done \
|
|
||||||
; fi
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Uninstall the software, completely.
|
# Uninstall the software, completely.
|
||||||
#
|
#
|
||||||
@@ -273,7 +258,7 @@ uninstall:
|
|||||||
#
|
#
|
||||||
# NOTE: Removes empty local directories.
|
# NOTE: Removes empty local directories.
|
||||||
#
|
#
|
||||||
update:
|
update:
|
||||||
hg pull --update 2>/dev/null
|
hg pull --update 2>/dev/null
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1163
bin/xen-create-image
1163
bin/xen-create-image
File diff suppressed because it is too large
Load Diff
@@ -130,7 +130,7 @@ $CONFIG{'template'} = '/etc/xen-tools/xm-nfs.tmpl';
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
# store version number away.
|
# store version number away.
|
||||||
@@ -140,7 +140,7 @@ $CONFIG{'xen_tools_version'} = $RELEASE;
|
|||||||
#
|
#
|
||||||
# Read the global configuration file.
|
# Read the global configuration file.
|
||||||
#
|
#
|
||||||
readConfigurationFile("/etc/xen-tools/xen-tools.conf");
|
readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -161,7 +161,7 @@ testArguments();
|
|||||||
if ( -e "/etc/xen/$CONFIG{'hostname'}.cfg" )
|
if ( -e "/etc/xen/$CONFIG{'hostname'}.cfg" )
|
||||||
{
|
{
|
||||||
die "Configuration file for $CONFIG{'hostname'} already exists"
|
die "Configuration file for $CONFIG{'hostname'} already exists"
|
||||||
unless ( $CONFIG{'force'} );
|
unless( $CONFIG{'force'} );
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -197,20 +197,20 @@ exit;
|
|||||||
|
|
||||||
sub readConfigurationFile
|
sub readConfigurationFile
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ($file) = ( @_ );
|
||||||
|
|
||||||
# Don't read the file if it doesn't exist.
|
# Don't read the file if it doesn't exist.
|
||||||
return if ( !-e $file );
|
return if ( ! -e $file );
|
||||||
|
|
||||||
|
|
||||||
my $line = "";
|
my $line = "";
|
||||||
|
|
||||||
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
||||||
|
|
||||||
while ( defined( $line = <FILE> ) )
|
while (defined($line = <FILE>) )
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ( $line =~ s/\\$// )
|
if ($line =~ s/\\$//)
|
||||||
{
|
{
|
||||||
$line .= <FILE>;
|
$line .= <FILE>;
|
||||||
redo unless eof(FILE);
|
redo unless eof(FILE);
|
||||||
@@ -220,7 +220,7 @@ sub readConfigurationFile
|
|||||||
next if ( $line =~ /^([ \t]*)\#/ );
|
next if ( $line =~ /^([ \t]*)\#/ );
|
||||||
|
|
||||||
# Skip blank lines
|
# Skip blank lines
|
||||||
next if ( length($line) < 1 );
|
next if ( length( $line ) < 1 );
|
||||||
|
|
||||||
# Strip trailing comments.
|
# Strip trailing comments.
|
||||||
if ( $line =~ /(.*)\#(.*)/ )
|
if ( $line =~ /(.*)\#(.*)/ )
|
||||||
@@ -243,7 +243,6 @@ sub readConfigurationFile
|
|||||||
# command expansion?
|
# command expansion?
|
||||||
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
# store
|
# store
|
||||||
my $pre = $1;
|
my $pre = $1;
|
||||||
my $cmd = $2;
|
my $cmd = $2;
|
||||||
@@ -251,18 +250,18 @@ sub readConfigurationFile
|
|||||||
|
|
||||||
# get output
|
# get output
|
||||||
my $output = `$cmd`;
|
my $output = `$cmd`;
|
||||||
chomp($output);
|
chomp( $output );
|
||||||
|
|
||||||
# build up replacement.
|
# build up replacement.
|
||||||
$val = $pre . $output . $post;
|
$val = $pre . $output . $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store value.
|
# Store value.
|
||||||
$CONFIG{$key} = $val;
|
$CONFIG{ $key } = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -287,48 +286,48 @@ sub parseCommandLineArguments
|
|||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
|
|
||||||
# Networking options
|
# Networking options
|
||||||
"dhcp", \$CONFIG{'dhcp'},
|
"dhcp", \$CONFIG{'dhcp'},
|
||||||
"gateway=s", \$CONFIG{'gateway'},
|
"gateway=s", \$CONFIG{'gateway'},
|
||||||
"broadcast=s", \$CONFIG{'broadcast'},
|
"broadcast=s", \$CONFIG{'broadcast'},
|
||||||
"ip=s", \$CONFIG{'ip'},
|
"ip=s", \$CONFIG{'ip'},
|
||||||
"netmask=s", \$CONFIG{'netmask'},
|
"netmask=s", \$CONFIG{'netmask'},
|
||||||
"hostname=s", \$CONFIG{'hostname'},
|
"hostname=s", \$CONFIG{'hostname'},
|
||||||
"memory=s", \$CONFIG{'memory'},
|
"memory=s", \$CONFIG{'memory'},
|
||||||
"mac=s", \$CONFIG{'mac'},
|
"mac=s", \$CONFIG{'mac'},
|
||||||
|
|
||||||
# NFS options.
|
# NFS options.
|
||||||
"nfs_server=s", \$CONFIG{'nfs_server'},
|
"nfs_server=s", \$CONFIG{'nfs_server'},
|
||||||
"nfs_root=s", \$CONFIG{'nfs_root'},
|
"nfs_root=s", \$CONFIG{'nfs_root'},
|
||||||
|
|
||||||
# Misc. options
|
# Misc. options
|
||||||
"admins=s", \$CONFIG{'admins'},
|
"admins=s", \$CONFIG{'admins'},
|
||||||
"kernel=s", \$CONFIG{'kernel'},
|
"kernel=s", \$CONFIG{'kernel'},
|
||||||
"initrd=s", \$CONFIG{'initrd'},
|
"initrd=s", \$CONFIG{'initrd'},
|
||||||
"force", \$CONFIG{'force'},
|
"force", \$CONFIG{'force'},
|
||||||
"template=s", \$CONFIG{'template'},
|
"template=s", \$CONFIG{'template'},
|
||||||
|
|
||||||
# Help options
|
# Help options
|
||||||
"help", \$HELP,
|
"help", \$HELP,
|
||||||
"manual", \$MANUAL,
|
"manual", \$MANUAL,
|
||||||
"verbose", \$CONFIG{'verbose'},
|
"verbose", \$CONFIG{'verbose'},
|
||||||
"version", \$VERSION
|
"version", \$VERSION
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.13 $';
|
my $REVISION = '$Revision: 1.13 $';
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
$REVISION = $1;
|
$REVISION = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
logprint("xen-create-nfs release $RELEASE - CVS: $REVISION\n");
|
logprint( "xen-create-nfs release $RELEASE - CVS: $REVISION\n" );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,11 +344,10 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub testArguments
|
sub testArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Hostname is mandatory
|
# Hostname is mandatory
|
||||||
#
|
#
|
||||||
die "No hostname" unless ( $CONFIG{'hostname'} );
|
die "No hostname" unless( $CONFIG{'hostname'} );
|
||||||
|
|
||||||
my @network = qw/ ip gateway netmask /;
|
my @network = qw/ ip gateway netmask /;
|
||||||
|
|
||||||
@@ -358,24 +356,24 @@ sub testArguments
|
|||||||
#
|
#
|
||||||
if ( $CONFIG{'dhcp'} )
|
if ( $CONFIG{'dhcp'} )
|
||||||
{
|
{
|
||||||
foreach my $f (@network)
|
foreach my $f ( @network )
|
||||||
{
|
{
|
||||||
delete( $CONFIG{$f} );
|
delete( $CONFIG{ $f } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach my $f (@network)
|
foreach my $f ( @network )
|
||||||
{
|
{
|
||||||
die "Missing --$f" unless ( $CONFIG{$f} );
|
die "Missing --$f" unless( $CONFIG{$f} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# We need an NFS server + root
|
# We need an NFS server + root
|
||||||
#
|
#
|
||||||
die "Missing NFS server." unless ( $CONFIG{'nfs_server'} );
|
die "Missing NFS server." unless( $CONFIG{'nfs_server'} );
|
||||||
die "Missing NFS root." unless ( $CONFIG{'nfs_root'} );
|
die "Missing NFS root." unless( $CONFIG{'nfs_root'} );
|
||||||
|
|
||||||
|
|
||||||
# All OK.
|
# All OK.
|
||||||
@@ -383,6 +381,7 @@ sub testArguments
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
This routine is designed to ensure that any users specified with
|
This routine is designed to ensure that any users specified with
|
||||||
@@ -394,7 +393,6 @@ sub testArguments
|
|||||||
|
|
||||||
sub setupAdminUsers
|
sub setupAdminUsers
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we're not root we can't modify users.
|
# If we're not root we can't modify users.
|
||||||
#
|
#
|
||||||
@@ -403,17 +401,16 @@ sub setupAdminUsers
|
|||||||
#
|
#
|
||||||
# If we don't have a sudoers file then we'll also ignore this.
|
# If we don't have a sudoers file then we'll also ignore this.
|
||||||
#
|
#
|
||||||
return if ( !-e "/etc/sudoers" );
|
return if ( ! -e "/etc/sudoers" );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find the path to the xen-login-shell
|
# Find the path to the xen-login-shell
|
||||||
#
|
#
|
||||||
my $shell = undef;
|
my $shell = undef;
|
||||||
$shell = "/usr/bin/xen-login-shell" if ( -x "/usr/bin/xen-login-shell" );
|
$shell = "/usr/bin/xen-login-shell" if ( -x "/usr/bin/xen-login-shell" );
|
||||||
$shell = "/usr/local/bin/xen-login-shell"
|
$shell = "/usr/local/bin/xen-login-shell" if ( -x "/usr/bin/local/xen-login-shell" );
|
||||||
if ( -x "/usr/bin/local/xen-login-shell" );
|
|
||||||
|
|
||||||
return if ( !defined($shell) );
|
return if ( !defined( $shell ) );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -422,7 +419,6 @@ sub setupAdminUsers
|
|||||||
#
|
#
|
||||||
foreach my $user ( split( /,/, $ENV{'admins'} ) )
|
foreach my $user ( split( /,/, $ENV{'admins'} ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
# Strip leading and trailing whitespace.
|
# Strip leading and trailing whitespace.
|
||||||
$user =~ s/^\s+//;
|
$user =~ s/^\s+//;
|
||||||
$user =~ s/\s+$//;
|
$user =~ s/\s+$//;
|
||||||
@@ -433,14 +429,12 @@ sub setupAdminUsers
|
|||||||
# Does the user exist?
|
# Does the user exist?
|
||||||
if ( getpwnam($user) )
|
if ( getpwnam($user) )
|
||||||
{
|
{
|
||||||
|
|
||||||
# Change shell.
|
# Change shell.
|
||||||
$CONFIG{'verbose'} && print "Changing shell for $user: $shell\n";
|
$CONFIG{'verbose'} && print "Changing shell for $user: $shell\n";
|
||||||
system( "chsh", "-s", $shell, $user );
|
system( "chsh", "-s", $shell, $user );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
# Add a new user.
|
# Add a new user.
|
||||||
$CONFIG{'verbose'} && print "Adding new user: $user\n";
|
$CONFIG{'verbose'} && print "Adding new user: $user\n";
|
||||||
system( "useradd", "-s", $shell, $user );
|
system( "useradd", "-s", $shell, $user );
|
||||||
@@ -449,11 +443,9 @@ sub setupAdminUsers
|
|||||||
#
|
#
|
||||||
# Add the entry to /etc/sudoers.
|
# Add the entry to /etc/sudoers.
|
||||||
#
|
#
|
||||||
open( SUDOERS, ">>", "/etc/sudoers" )
|
open( SUDOERS, ">>", "/etc/sudoers" ) or warn "Failed to add user to sudoers file : $user - $!";
|
||||||
or warn "Failed to add user to sudoers file : $user - $!";
|
print SUDOERS "$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n";
|
||||||
print SUDOERS
|
close( SUDOERS );
|
||||||
"$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n";
|
|
||||||
close(SUDOERS);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,8 +461,7 @@ sub setupAdminUsers
|
|||||||
|
|
||||||
sub createNewConfigurationFile
|
sub createNewConfigurationFile
|
||||||
{
|
{
|
||||||
die "Template file missing: $CONFIG{'template'}"
|
die "Template file missing: $CONFIG{'template'}" unless( -e $CONFIG{'template'} );
|
||||||
unless ( -e $CONFIG{'template'} );
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Load the template.
|
# Load the template.
|
||||||
@@ -478,7 +469,7 @@ sub createNewConfigurationFile
|
|||||||
my $template = new Text::Template( TYPE => 'FILE',
|
my $template = new Text::Template( TYPE => 'FILE',
|
||||||
SOURCE => $CONFIG{'template'} );
|
SOURCE => $CONFIG{'template'} );
|
||||||
|
|
||||||
my $result = $template->fill_in( HASH => \%CONFIG );
|
my $result = $template->fill_in( HASH => \%CONFIG );
|
||||||
|
|
||||||
#
|
#
|
||||||
# The file we'll write to.
|
# The file we'll write to.
|
||||||
@@ -490,5 +481,5 @@ sub createNewConfigurationFile
|
|||||||
#
|
#
|
||||||
open( FILE, ">", $file ) or die "Failed to write to $file - $!";
|
open( FILE, ">", $file ) or die "Failed to write to $file - $!";
|
||||||
print FILE $result;
|
print FILE $result;
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,8 @@ my %CONFIG;
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ my $RELEASE = '4.1';
|
|||||||
#
|
#
|
||||||
if ( -e "/etc/xen-tools/xen-tools.conf" )
|
if ( -e "/etc/xen-tools/xen-tools.conf" )
|
||||||
{
|
{
|
||||||
readConfigurationFile("/etc/xen-tools/xen-tools.conf");
|
readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -198,7 +199,7 @@ checkArguments();
|
|||||||
#
|
#
|
||||||
# Abort if non-root user.
|
# Abort if non-root user.
|
||||||
#
|
#
|
||||||
if ( ( !$CONFIG{'test'} ) && ( $EFFECTIVE_USER_ID != 0 ) )
|
if ( (!$CONFIG{'test'}) && ( $EFFECTIVE_USER_ID != 0 ) )
|
||||||
{
|
{
|
||||||
print <<E_O_ROOT;
|
print <<E_O_ROOT;
|
||||||
|
|
||||||
@@ -216,11 +217,11 @@ E_O_ROOT
|
|||||||
# Loop over the supplied arguments, and attempt to delete each
|
# Loop over the supplied arguments, and attempt to delete each
|
||||||
# image.
|
# image.
|
||||||
#
|
#
|
||||||
while ( my $name = shift )
|
while( my $name = shift )
|
||||||
{
|
{
|
||||||
if ( !xenRunning($name) )
|
if ( !xenRunning( $name ) )
|
||||||
{
|
{
|
||||||
deleteXenImage($name);
|
deleteXenImage( $name );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -232,11 +233,11 @@ while ( my $name = shift )
|
|||||||
# Also delete any which were specified using the --hostname flag
|
# Also delete any which were specified using the --hostname flag
|
||||||
#
|
#
|
||||||
my $hosts = $CONFIG{'hostname'};
|
my $hosts = $CONFIG{'hostname'};
|
||||||
foreach my $name (@$hosts)
|
foreach my $name ( @$hosts )
|
||||||
{
|
{
|
||||||
if ( !xenRunning($name) )
|
if ( !xenRunning( $name ) )
|
||||||
{
|
{
|
||||||
deleteXenImage($name);
|
deleteXenImage( $name );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -251,6 +252,7 @@ exit 0;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Read the configuration file specified.
|
Read the configuration file specified.
|
||||||
@@ -261,16 +263,16 @@ exit 0;
|
|||||||
|
|
||||||
sub readConfigurationFile
|
sub readConfigurationFile
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ($file) = ( @_ );
|
||||||
|
|
||||||
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
||||||
|
|
||||||
my $line = "";
|
my $line = "";
|
||||||
|
|
||||||
while ( defined( $line = <FILE> ) )
|
while (defined($line = <FILE>) )
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ( $line =~ s/\\$// )
|
if ($line =~ s/\\$//)
|
||||||
{
|
{
|
||||||
$line .= <FILE>;
|
$line .= <FILE>;
|
||||||
redo unless eof(FILE);
|
redo unless eof(FILE);
|
||||||
@@ -280,7 +282,7 @@ sub readConfigurationFile
|
|||||||
next if ( $line =~ /^([ \t]*)\#/ );
|
next if ( $line =~ /^([ \t]*)\#/ );
|
||||||
|
|
||||||
# Skip blank lines
|
# Skip blank lines
|
||||||
next if ( length($line) < 1 );
|
next if ( length( $line ) < 1 );
|
||||||
|
|
||||||
# Strip trailing comments.
|
# Strip trailing comments.
|
||||||
if ( $line =~ /(.*)\#(.*)/ )
|
if ( $line =~ /(.*)\#(.*)/ )
|
||||||
@@ -303,7 +305,6 @@ sub readConfigurationFile
|
|||||||
# command expansion?
|
# command expansion?
|
||||||
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
# store
|
# store
|
||||||
my $pre = $1;
|
my $pre = $1;
|
||||||
my $cmd = $2;
|
my $cmd = $2;
|
||||||
@@ -311,22 +312,23 @@ sub readConfigurationFile
|
|||||||
|
|
||||||
# get output
|
# get output
|
||||||
my $output = `$cmd`;
|
my $output = `$cmd`;
|
||||||
chomp($output);
|
chomp( $output );
|
||||||
|
|
||||||
# build up replacement.
|
# build up replacement.
|
||||||
$val = $pre . $output . $post;
|
$val = $pre . $output . $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store value.
|
# Store value.
|
||||||
$CONFIG{$key} = $val;
|
$CONFIG{ $key } = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Parse the arguments specified upon the command line.
|
Parse the arguments specified upon the command line.
|
||||||
@@ -344,32 +346,32 @@ sub parseCommandLineArguments
|
|||||||
# Parse options.
|
# Parse options.
|
||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
"dir=s", \$CONFIG{'dir'},
|
"dir=s", \$CONFIG{'dir'},
|
||||||
"lvm=s", \$CONFIG{'lvm'},
|
"lvm=s", \$CONFIG{'lvm'},
|
||||||
"evms=s", \$CONFIG{'evms'},
|
"evms=s", \$CONFIG{'evms'},
|
||||||
"hostname=s@", \$CONFIG{'hostname'},
|
"hostname=s@", \$CONFIG{'hostname'},
|
||||||
"test", \$CONFIG{'test'},
|
"test", \$CONFIG{'test'},
|
||||||
"verbose", \$CONFIG{'verbose'},
|
"verbose", \$CONFIG{'verbose'},
|
||||||
"help", \$HELP,
|
"help", \$HELP,
|
||||||
"manual", \$MANUAL,
|
"manual", \$MANUAL,
|
||||||
"version", \$VERSION
|
"version", \$VERSION
|
||||||
);
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.41 $';
|
my $REVISION = '$Revision: 1.41 $';
|
||||||
|
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
$REVISION = $1;
|
$REVISION = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "xen-delete-image release $RELEASE - CVS: $REVISION\n";
|
print "xen-delete-image release $RELEASE - CVS: $REVISION\n";
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,7 +388,6 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub checkArguments
|
sub checkArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# When testing we only care about loopback images, not disk images.
|
# When testing we only care about loopback images, not disk images.
|
||||||
#
|
#
|
||||||
@@ -400,7 +401,7 @@ sub checkArguments
|
|||||||
# Make sure we got one and only one installation method.
|
# Make sure we got one and only one installation method.
|
||||||
#
|
#
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach my $type (qw/dir lvm evms/)
|
foreach my $type ( qw/dir lvm evms/ )
|
||||||
{
|
{
|
||||||
$count += 1 if defined( $CONFIG{$type} );
|
$count += 1 if defined( $CONFIG{$type} );
|
||||||
}
|
}
|
||||||
@@ -411,16 +412,17 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
if ( $count != 1 )
|
if ( $count != 1 )
|
||||||
{
|
{
|
||||||
print "Please select one and only one of the installation methods:\n";
|
print "Please select one and only one of the installation methods:\n";
|
||||||
print " --dir\n";
|
print " --dir\n";
|
||||||
print " --evms\n";
|
print " --evms\n";
|
||||||
print " --lvm\n";
|
print " --lvm\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Test to see if the given instance is running.
|
Test to see if the given instance is running.
|
||||||
@@ -431,20 +433,20 @@ sub checkArguments
|
|||||||
|
|
||||||
sub xenRunning
|
sub xenRunning
|
||||||
{
|
{
|
||||||
my ($hostname) = (@_);
|
my( $hostname ) = (@_ );
|
||||||
|
|
||||||
my $running = 0;
|
my $running = 0;
|
||||||
|
|
||||||
open( CMD, "xm list $hostname 2>/dev/null |" )
|
open( CMD, "xm list $hostname 2>/dev/null |")
|
||||||
or die "Failed to run 'xm list $hostname'";
|
or die "Failed to run 'xm list $hostname'";
|
||||||
while (<CMD>)
|
while( <CMD> )
|
||||||
{
|
{
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
$running = 1 if ( $line =~ /\Q$hostname\E/ );
|
$running = 1 if ( $line =~ /\Q$hostname\E/ )
|
||||||
}
|
}
|
||||||
close(CMD);
|
close( CMD );
|
||||||
|
|
||||||
return ($running);
|
return( $running );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -459,7 +461,7 @@ sub xenRunning
|
|||||||
|
|
||||||
sub deleteXenImage
|
sub deleteXenImage
|
||||||
{
|
{
|
||||||
my ($hostname) = (@_);
|
my ($hostname) = ( @_ );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Collect the names of files to delete.
|
# Collect the names of files to delete.
|
||||||
@@ -485,12 +487,12 @@ sub deleteXenImage
|
|||||||
#
|
#
|
||||||
# If we're working on disk images remove them.
|
# If we're working on disk images remove them.
|
||||||
#
|
#
|
||||||
foreach my $file (@delete)
|
foreach my $file ( @delete )
|
||||||
{
|
{
|
||||||
if ( -e $file )
|
if ( -e $file )
|
||||||
{
|
{
|
||||||
print "Deleting: $file\n";
|
print "Deleting: $file\n";
|
||||||
unlink($file);
|
unlink( $file );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -501,71 +503,69 @@ sub deleteXenImage
|
|||||||
|
|
||||||
if ( defined( $CONFIG{'dir'} ) )
|
if ( defined( $CONFIG{'dir'} ) )
|
||||||
{
|
{
|
||||||
my $prefix = $CONFIG{'dir'} . "/domains/";
|
my $prefix = $CONFIG{'dir'} . "/domains/";
|
||||||
|
|
||||||
#
|
#
|
||||||
# Now remove the directory.
|
# Now remove the directory.
|
||||||
#
|
#
|
||||||
if ( -d $prefix . $hostname )
|
if ( -d $prefix . $hostname )
|
||||||
{
|
{
|
||||||
print "Removing: " . $prefix . $hostname . "\n";
|
print "Removing: " . $prefix . $hostname . "\n";
|
||||||
rmdir( $prefix . $hostname );
|
rmdir ( $prefix . $hostname );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( defined( $CONFIG{'lvm'} ) )
|
elsif ( defined( $CONFIG{'lvm'} ) )
|
||||||
{
|
{
|
||||||
|
#
|
||||||
|
# LVM volumes
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# TODO: Check we're not mounted.
|
||||||
|
#
|
||||||
|
|
||||||
#
|
if ( -e "/dev/$CONFIG{'lvm'}/$hostname-swap" )
|
||||||
# LVM volumes
|
{
|
||||||
#
|
print "Removing swap volume\n";
|
||||||
#
|
runCommand( "lvremove /dev/$CONFIG{'lvm'}/$hostname-swap --force" );
|
||||||
# TODO: Check we're not mounted.
|
}
|
||||||
#
|
|
||||||
|
|
||||||
if ( -e "/dev/$CONFIG{'lvm'}/$hostname-swap" )
|
if ( -e "/dev/$CONFIG{'lvm'}/$hostname-disk" )
|
||||||
{
|
{
|
||||||
print "Removing swap volume\n";
|
print "Removing LVM disk volume\n";
|
||||||
runCommand("lvremove /dev/$CONFIG{'lvm'}/$hostname-swap --force");
|
runCommand( "lvremove /dev/$CONFIG{'lvm'}/$hostname-disk --force" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( -e "/dev/$CONFIG{'lvm'}/$hostname-disk" )
|
|
||||||
{
|
|
||||||
print "Removing LVM disk volume\n";
|
|
||||||
runCommand("lvremove /dev/$CONFIG{'lvm'}/$hostname-disk --force");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( defined( $CONFIG{'evms'} ) )
|
elsif ( defined( $CONFIG{'evms'} ) )
|
||||||
{
|
{
|
||||||
|
#
|
||||||
|
# EVMS volumes
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# TODO: Check we're not mounted.
|
||||||
|
#
|
||||||
|
|
||||||
#
|
if ( -e "/dev/evms/$hostname-swap" )
|
||||||
# EVMS volumes
|
{
|
||||||
#
|
print "Removing EVMS swap volume\n";
|
||||||
#
|
runCommand( "echo Delete : /dev/evms/$hostname-swap | evms" );
|
||||||
# TODO: Check we're not mounted.
|
runCommand( "echo Delete : $CONFIG{'evms'}/$hostname-swap | evms" );
|
||||||
#
|
}
|
||||||
|
|
||||||
if ( -e "/dev/evms/$hostname-swap" )
|
if ( -e "/dev/evms/$hostname-disk" )
|
||||||
{
|
{
|
||||||
print "Removing EVMS swap volume\n";
|
print "Removing EVMS disk volume\n";
|
||||||
runCommand("echo Delete : /dev/evms/$hostname-swap | evms");
|
runCommand( "echo Delete : /dev/evms/$hostname-disk | evms" );
|
||||||
runCommand("echo Delete : $CONFIG{'evms'}/$hostname-swap | evms");
|
runCommand( "echo Delete : $CONFIG{'evms'}/$hostname-disk | evms" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( -e "/dev/evms/$hostname-disk" )
|
|
||||||
{
|
|
||||||
print "Removing EVMS disk volume\n";
|
|
||||||
runCommand("echo Delete : /dev/evms/$hostname-disk | evms");
|
|
||||||
runCommand("echo Delete : $CONFIG{'evms'}/$hostname-disk | evms");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "Error: No installation type specified\n";
|
print "Error: No installation type specified\n";
|
||||||
print "Can't happen!\n";
|
print "Can't happen!\n";
|
||||||
print "Hostname : $hostname\n";
|
print "Hostname : $hostname\n";
|
||||||
exit 127;
|
exit 127;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +584,7 @@ sub deleteXenImage
|
|||||||
|
|
||||||
sub runCommand
|
sub runCommand
|
||||||
{
|
{
|
||||||
my ($cmd) = (@_);
|
my ( $cmd ) = (@_ );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Header.
|
# Header.
|
||||||
@@ -596,15 +596,14 @@ sub runCommand
|
|||||||
#
|
#
|
||||||
if ( $CONFIG{'verbose'} )
|
if ( $CONFIG{'verbose'} )
|
||||||
{
|
{
|
||||||
|
#
|
||||||
#
|
# Copy stderr to stdout, so we can see it.
|
||||||
# Copy stderr to stdout, so we can see it.
|
#
|
||||||
#
|
$cmd .= " 2>&1";
|
||||||
$cmd .= " 2>&1";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$cmd .= " >/dev/null 2>/dev/null";
|
$cmd .= " >/dev/null 2>/dev/null" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -615,9 +614,9 @@ sub runCommand
|
|||||||
|
|
||||||
if ( $? != 0 )
|
if ( $? != 0 )
|
||||||
{
|
{
|
||||||
print "Running command '$cmd' failed.\n";
|
print "Running command '$cmd' failed.\n";
|
||||||
print "Aborting\n";
|
print "Aborting\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -629,5 +628,5 @@ sub runCommand
|
|||||||
$CONFIG{'verbose'} && print $output . "\n";
|
$CONFIG{'verbose'} && print $output . "\n";
|
||||||
$CONFIG{'verbose'} && print "Finished : $cmd\n";
|
$CONFIG{'verbose'} && print "Finished : $cmd\n";
|
||||||
|
|
||||||
return ($output);
|
return( $output );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,14 +102,14 @@ $CONFIG{'prefix'} = "/etc/xen";
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read the global configuration file if it exists.
|
# Read the global configuration file if it exists.
|
||||||
#
|
#
|
||||||
readConfigurationFile("/etc/xen-tools/xen-tools.conf");
|
readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -129,11 +129,11 @@ my @instances = findXenInstances();
|
|||||||
# Now process each instance.
|
# Now process each instance.
|
||||||
#
|
#
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach my $instance (@instances)
|
foreach my $instance ( @instances )
|
||||||
{
|
{
|
||||||
if ($count) { print "\n"; }
|
if ( $count ) { print "\n"; }
|
||||||
|
|
||||||
displayInstance($instance);
|
displayInstance( $instance );
|
||||||
$count += 1;
|
$count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,18 +155,18 @@ exit;
|
|||||||
|
|
||||||
sub readConfigurationFile
|
sub readConfigurationFile
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ($file) = ( @_ );
|
||||||
|
|
||||||
# Don't read the file if it doesn't exist.
|
# Don't read the file if it doesn't exist.
|
||||||
return if ( !-e $file );
|
return if ( ! -e $file );
|
||||||
|
|
||||||
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
||||||
|
|
||||||
|
|
||||||
while ( defined( my $line = <FILE> ) )
|
while (defined(my $line = <FILE>) )
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ( $line =~ s/\\$// )
|
if ($line =~ s/\\$//)
|
||||||
{
|
{
|
||||||
$line .= <FILE>;
|
$line .= <FILE>;
|
||||||
redo unless eof(FILE);
|
redo unless eof(FILE);
|
||||||
@@ -176,7 +176,7 @@ sub readConfigurationFile
|
|||||||
next if ( $line =~ /^([ \t]*)\#/ );
|
next if ( $line =~ /^([ \t]*)\#/ );
|
||||||
|
|
||||||
# Skip blank lines
|
# Skip blank lines
|
||||||
next if ( length($line) < 1 );
|
next if ( length( $line ) < 1 );
|
||||||
|
|
||||||
# Strip trailing comments.
|
# Strip trailing comments.
|
||||||
if ( $line =~ /(.*)\#(.*)/ )
|
if ( $line =~ /(.*)\#(.*)/ )
|
||||||
@@ -199,7 +199,6 @@ sub readConfigurationFile
|
|||||||
# command expansion?
|
# command expansion?
|
||||||
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
# store
|
# store
|
||||||
my $pre = $1;
|
my $pre = $1;
|
||||||
my $cmd = $2;
|
my $cmd = $2;
|
||||||
@@ -207,21 +206,22 @@ sub readConfigurationFile
|
|||||||
|
|
||||||
# get output
|
# get output
|
||||||
my $output = `$cmd`;
|
my $output = `$cmd`;
|
||||||
chomp($output);
|
chomp( $output );
|
||||||
|
|
||||||
# build up replacement.
|
# build up replacement.
|
||||||
$val = $pre . $output . $post;
|
$val = $pre . $output . $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store value.
|
# Store value.
|
||||||
$CONFIG{$key} = $val;
|
$CONFIG{ $key } = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Parse the arguments specified upon the command line.
|
Parse the arguments specified upon the command line.
|
||||||
@@ -234,20 +234,24 @@ sub parseCommandLineArguments
|
|||||||
{
|
{
|
||||||
my $HELP = 0;
|
my $HELP = 0;
|
||||||
my $MANUAL = 0;
|
my $MANUAL = 0;
|
||||||
my $VERSION = 0;
|
my $VERSION = 0;
|
||||||
|
|
||||||
# Parse options.
|
# Parse options.
|
||||||
#
|
#
|
||||||
GetOptions( "test=s", \$CONFIG{'prefix'}, "help", \$HELP, "manual",
|
GetOptions(
|
||||||
\$MANUAL, "version", \$VERSION );
|
"test=s", \$CONFIG{'prefix'},
|
||||||
|
"help", \$HELP,
|
||||||
|
"manual", \$MANUAL,
|
||||||
|
"version", \$VERSION
|
||||||
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.30 $';
|
my $REVISION = '$Revision: 1.30 $';
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
$REVISION = $1;
|
$REVISION = $1;
|
||||||
@@ -278,7 +282,7 @@ sub findXenInstances
|
|||||||
push @found, $file if ( -e $file );
|
push @found, $file if ( -e $file );
|
||||||
}
|
}
|
||||||
|
|
||||||
return (@found);
|
return( @found );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -294,14 +298,14 @@ sub findXenInstances
|
|||||||
|
|
||||||
sub displayInstance
|
sub displayInstance
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ( $file ) = ( @_ );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read each line.
|
# Read each line.
|
||||||
#
|
#
|
||||||
open( FILY, "<", $file );
|
open( FILY, "<", $file );
|
||||||
my @LINES = <FILY>;
|
my @LINES = <FILY>;
|
||||||
close(FILY);
|
close( FILY );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Is it dynamic?
|
# Is it dynamic?
|
||||||
@@ -312,7 +316,7 @@ sub displayInstance
|
|||||||
my $name = '';
|
my $name = '';
|
||||||
my $mem = 0;
|
my $mem = 0;
|
||||||
|
|
||||||
foreach my $line (@LINES)
|
foreach my $line ( @LINES )
|
||||||
{
|
{
|
||||||
if ( $line =~ /^\s*dhcp\s*=\s*"dhcp\"/i )
|
if ( $line =~ /^\s*dhcp\s*=\s*"dhcp\"/i )
|
||||||
{
|
{
|
||||||
@@ -338,7 +342,7 @@ sub displayInstance
|
|||||||
|
|
||||||
print "Name: $name\n";
|
print "Name: $name\n";
|
||||||
print "Memory: $mem\n";
|
print "Memory: $mem\n";
|
||||||
print "IP: " . $ip . $mac . "\n" if length($ip);
|
print "IP: " . $ip . $mac . "\n" if length( $ip );
|
||||||
print "DHCP" . $mac . "\n" if $dhcp;
|
print "DHCP" . $mac . "\n" if $dhcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ use Text::Template;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configuration values read from the command line, or configuration file.
|
# Configuration values read from the command line, or configuration file.
|
||||||
#
|
#
|
||||||
@@ -116,14 +118,14 @@ my %CONFIG;
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read the global configuration file.
|
# Read the global configuration file.
|
||||||
#
|
#
|
||||||
readConfigurationFile("/etc/xen-tools/xen-tools.conf");
|
readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -145,12 +147,11 @@ my $path = undef;
|
|||||||
|
|
||||||
if ( $CONFIG{'dir'} )
|
if ( $CONFIG{'dir'} )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Make sure we can find the disk
|
# Make sure we can find the disk
|
||||||
#
|
#
|
||||||
$path = $CONFIG{'dir'} . "/domains/" . $CONFIG{'hostname'} . "/disk.img";
|
$path = $CONFIG{'dir'} . "/domains/" . $CONFIG{'hostname'} . "/disk.img";
|
||||||
if ( !-e $path )
|
if ( ! -e $path )
|
||||||
{
|
{
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
|
|
||||||
@@ -200,16 +201,15 @@ EOF
|
|||||||
print "DO NOT INTERRUPT\n";
|
print "DO NOT INTERRUPT\n";
|
||||||
|
|
||||||
my $cmd = "dd if=/dev/zero bs=1M count=$CONFIG{'add'}k >> $path";
|
my $cmd = "dd if=/dev/zero bs=1M count=$CONFIG{'add'}k >> $path";
|
||||||
system($cmd );
|
system( $cmd );
|
||||||
}
|
}
|
||||||
elsif ( $CONFIG{'lvm'} )
|
elsif ( $CONFIG{'lvm'} )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Make sure we can find the disk
|
# Make sure we can find the disk
|
||||||
#
|
#
|
||||||
$path = "/dev/" . $CONFIG{'lvm'} . "/" . $CONFIG{'hostname'} . "-disk";
|
$path = "/dev/" . $CONFIG{'lvm'} . "/" . $CONFIG{'hostname'} . "-disk";
|
||||||
if ( !-e $path )
|
if ( ! -e $path )
|
||||||
{
|
{
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ EOF
|
|||||||
|
|
||||||
print "DO NOT INTERRUPT\n";
|
print "DO NOT INTERRUPT\n";
|
||||||
my $cmd = "lvextend -L+$CONFIG{'add'}M $path";
|
my $cmd = "lvextend -L+$CONFIG{'add'}M $path";
|
||||||
system($cmd );
|
system( $cmd );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -271,13 +271,13 @@ else
|
|||||||
# Check filesystem.
|
# Check filesystem.
|
||||||
#
|
#
|
||||||
print "Checking filesystem\n";
|
print "Checking filesystem\n";
|
||||||
system("fsck.ext3 -f $path");
|
system( "fsck.ext3 -f $path" );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Run ext3resize.
|
# Run ext3resize.
|
||||||
#
|
#
|
||||||
print "Resizing in place\n";
|
print "Resizing in place\n";
|
||||||
system("resize2fs $path");
|
system( "resize2fs $path" );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -298,16 +298,16 @@ exit 0;
|
|||||||
|
|
||||||
sub readConfigurationFile
|
sub readConfigurationFile
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ($file) = ( @_ );
|
||||||
|
|
||||||
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
||||||
|
|
||||||
my $line = "";
|
my $line = "";
|
||||||
|
|
||||||
while ( defined( $line = <FILE> ) )
|
while (defined($line = <FILE>) )
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ( $line =~ s/\\$// )
|
if ($line =~ s/\\$//)
|
||||||
{
|
{
|
||||||
$line .= <FILE>;
|
$line .= <FILE>;
|
||||||
redo unless eof(FILE);
|
redo unless eof(FILE);
|
||||||
@@ -317,7 +317,7 @@ sub readConfigurationFile
|
|||||||
next if ( $line =~ /^([ \t]*)\#/ );
|
next if ( $line =~ /^([ \t]*)\#/ );
|
||||||
|
|
||||||
# Skip blank lines
|
# Skip blank lines
|
||||||
next if ( length($line) < 1 );
|
next if ( length( $line ) < 1 );
|
||||||
|
|
||||||
# Strip trailing comments.
|
# Strip trailing comments.
|
||||||
if ( $line =~ /(.*)\#(.*)/ )
|
if ( $line =~ /(.*)\#(.*)/ )
|
||||||
@@ -340,7 +340,6 @@ sub readConfigurationFile
|
|||||||
# command expansion?
|
# command expansion?
|
||||||
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
# store
|
# store
|
||||||
my $pre = $1;
|
my $pre = $1;
|
||||||
my $cmd = $2;
|
my $cmd = $2;
|
||||||
@@ -348,18 +347,18 @@ sub readConfigurationFile
|
|||||||
|
|
||||||
# get output
|
# get output
|
||||||
my $output = `$cmd`;
|
my $output = `$cmd`;
|
||||||
chomp($output);
|
chomp( $output );
|
||||||
|
|
||||||
# build up replacement.
|
# build up replacement.
|
||||||
$val = $pre . $output . $post;
|
$val = $pre . $output . $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store value.
|
# Store value.
|
||||||
$CONFIG{$key} = $val;
|
$CONFIG{ $key } = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -388,27 +387,27 @@ sub parseCommandLineArguments
|
|||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
|
|
||||||
# Misc. options
|
# Misc. options
|
||||||
"add=s", \$CONFIG{'add'},
|
"add=s", \$CONFIG{'add'},
|
||||||
"dir=s", \$install{'dir'},
|
"dir=s", \$install{'dir'},
|
||||||
"lvm=s", \$install{'lvm'},
|
"lvm=s", \$install{'lvm'},
|
||||||
"hostname=s", \$CONFIG{'hostname'},
|
"hostname=s", \$CONFIG{'hostname'},
|
||||||
"force", \$CONFIG{'force'},
|
"force", \$CONFIG{'force'},
|
||||||
|
|
||||||
# Help options
|
# Help options
|
||||||
"help", \$HELP,
|
"help", \$HELP,
|
||||||
"manual", \$MANUAL,
|
"manual", \$MANUAL,
|
||||||
"verbose", \$CONFIG{'verbose'},
|
"verbose", \$CONFIG{'verbose'},
|
||||||
"version", \$VERSION
|
"version", \$VERSION
|
||||||
);
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
print("xen-resize-guest release $RELEASE\n");
|
print( "xen-resize-guest release $RELEASE\n" );
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,7 +442,6 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub testArguments
|
sub testArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Make sure we received a hostname.
|
# Make sure we received a hostname.
|
||||||
#
|
#
|
||||||
@@ -488,8 +486,8 @@ EOF
|
|||||||
# We should either have LVM *or* directory - not neither or both.
|
# We should either have LVM *or* directory - not neither or both.
|
||||||
#
|
#
|
||||||
my $options = 0;
|
my $options = 0;
|
||||||
$options += 1 if ( defined( $CONFIG{'lvm'} ) && length( $CONFIG{'lvm'} ) );
|
$options += 1if ( defined($CONFIG{'lvm'}) && length( $CONFIG{'lvm'} ) );
|
||||||
$options += 1 if ( defined( $CONFIG{'dir'} ) && length( $CONFIG{'dir'} ) );
|
$options += 1if ( defined($CONFIG{'dir'}) && length( $CONFIG{'dir'} ) );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Report
|
# Report
|
||||||
@@ -530,18 +528,18 @@ EOF
|
|||||||
|
|
||||||
sub xenRunning
|
sub xenRunning
|
||||||
{
|
{
|
||||||
my ($hostname) = (@_);
|
my( $hostname ) = (@_ );
|
||||||
|
|
||||||
my $running = 0;
|
my $running = 0;
|
||||||
|
|
||||||
open( CMD, "xm list $hostname 2>/dev/null |" )
|
open( CMD, "xm list $hostname 2>/dev/null |")
|
||||||
or die "Failed to run 'xm list $hostname'";
|
or die "Failed to run 'xm list $hostname'";
|
||||||
while (<CMD>)
|
while( <CMD> )
|
||||||
{
|
{
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
$running = 1 if ( $line =~ /\Q$hostname\E/ );
|
$running = 1 if ( $line =~ /\Q$hostname\E/ )
|
||||||
}
|
}
|
||||||
close(CMD);
|
close( CMD );
|
||||||
|
|
||||||
return ($running);
|
return( $running );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ my %CONFIG;
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -128,7 +128,7 @@ my $RELEASE = '4.1';
|
|||||||
#
|
#
|
||||||
if ( -e "/etc/xen-tools/xen-tools.conf" )
|
if ( -e "/etc/xen-tools/xen-tools.conf" )
|
||||||
{
|
{
|
||||||
readConfigurationFile("/etc/xen-tools/xen-tools.conf");
|
readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,11 +166,11 @@ E_O_ROOT
|
|||||||
#
|
#
|
||||||
# Loop over the supplied arguments, and attempt to update each image.
|
# Loop over the supplied arguments, and attempt to update each image.
|
||||||
#
|
#
|
||||||
while ( my $name = shift )
|
while( my $name = shift )
|
||||||
{
|
{
|
||||||
if ( !xenRunning($name) )
|
if ( !xenRunning( $name ) )
|
||||||
{
|
{
|
||||||
updateXenImage($name);
|
updateXenImage( $name );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -196,7 +196,7 @@ exit;
|
|||||||
|
|
||||||
sub updateXenImage
|
sub updateXenImage
|
||||||
{
|
{
|
||||||
my ($name) = (@_);
|
my ( $name ) = ( @_ );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Create a temporary directory, and prepare to mount the
|
# Create a temporary directory, and prepare to mount the
|
||||||
@@ -212,11 +212,10 @@ sub updateXenImage
|
|||||||
#
|
#
|
||||||
if ( $CONFIG{'dir'} )
|
if ( $CONFIG{'dir'} )
|
||||||
{
|
{
|
||||||
|
|
||||||
# The loopback image.
|
# The loopback image.
|
||||||
$img = $CONFIG{'dir'} . "/domains/" . $name . "/disk.img";
|
$img = $CONFIG{'dir'} . "/domains/" . $name . "/disk.img";
|
||||||
|
|
||||||
if ( !-e $img )
|
if ( ! -e $img )
|
||||||
{
|
{
|
||||||
print "Disk image '$img' for host '$name' not found\n";
|
print "Disk image '$img' for host '$name' not found\n";
|
||||||
return;
|
return;
|
||||||
@@ -226,12 +225,11 @@ sub updateXenImage
|
|||||||
}
|
}
|
||||||
elsif ( $CONFIG{'lvm'} )
|
elsif ( $CONFIG{'lvm'} )
|
||||||
{
|
{
|
||||||
|
|
||||||
# The LVM volume
|
# The LVM volume
|
||||||
$img = "/dev/" . $CONFIG{'lvm'} . "/$name-disk";
|
$img = "/dev/" . $CONFIG{'lvm'} . "/$name-disk";
|
||||||
|
|
||||||
# make sure it exists.
|
# make sure it exists.
|
||||||
if ( !-e $img )
|
if ( ! -e $img )
|
||||||
{
|
{
|
||||||
print "Logical volume '$img' for host '$name' not found\n";
|
print "Logical volume '$img' for host '$name' not found\n";
|
||||||
return;
|
return;
|
||||||
@@ -241,24 +239,23 @@ sub updateXenImage
|
|||||||
}
|
}
|
||||||
elsif ( $CONFIG{'evms'} )
|
elsif ( $CONFIG{'evms'} )
|
||||||
{
|
{
|
||||||
|
# The EVMS volume -- note, unlike LVM, you don't need the $CONFIG{'evms'}
|
||||||
|
# to see it and mount the volume. $CONFIG{'evms'} is only used for manipulating
|
||||||
|
# the underlying object. Still, I don't want to mess with the parse code and
|
||||||
|
# make it confusing - otherwise --evms takes an argument everywhere but here,
|
||||||
|
# which will confuse users. The better solution is to make it so that --evms can
|
||||||
|
# take a following container, but doesn't require it. For the moment, it is
|
||||||
|
# better to leave it as it is, take a container, and then ignore it.
|
||||||
|
|
||||||
# The EVMS volume -- note, unlike LVM, you don't need the $CONFIG{'evms'}
|
# The best way to do it is to just read it out of the configuration file,
|
||||||
# to see it and mount the volume. $CONFIG{'evms'} is only used for manipulating
|
# tell the user what you got and where you got it from, and not bother the user
|
||||||
# the underlying object. Still, I don't want to mess with the parse code and
|
# with picking --dir or --lvm or --evms at all, but infer it from the config
|
||||||
# make it confusing - otherwise --evms takes an argument everywhere but here,
|
# file's disk = parameter. xen-delete-image might work the same way, but
|
||||||
# which will confuse users. The better solution is to make it so that --evms can
|
# it could be *slightly* more dangerous in the context of deleting.
|
||||||
# take a following container, but doesn't require it. For the moment, it is
|
|
||||||
# better to leave it as it is, take a container, and then ignore it.
|
|
||||||
|
|
||||||
# The best way to do it is to just read it out of the configuration file,
|
|
||||||
# tell the user what you got and where you got it from, and not bother the user
|
|
||||||
# with picking --dir or --lvm or --evms at all, but infer it from the config
|
|
||||||
# file's disk = parameter. xen-delete-image might work the same way, but
|
|
||||||
# it could be *slightly* more dangerous in the context of deleting.
|
|
||||||
$img = "/dev/evms/$name-disk";
|
$img = "/dev/evms/$name-disk";
|
||||||
|
|
||||||
# make sure it exists.
|
# make sure it exists.
|
||||||
if ( !-e $img )
|
if ( ! -e $img )
|
||||||
{
|
{
|
||||||
print "EVMS volume '$img' for host '$name' not found\n";
|
print "EVMS volume '$img' for host '$name' not found\n";
|
||||||
return;
|
return;
|
||||||
@@ -279,26 +276,23 @@ sub updateXenImage
|
|||||||
#
|
#
|
||||||
# Make sure this is a Debian image.
|
# Make sure this is a Debian image.
|
||||||
#
|
#
|
||||||
if ( ( -e $tmp . "/usr/bin/apt-get" )
|
if ( ( -e $tmp . "/usr/bin/apt-get" ) &&
|
||||||
&& ( -x $tmp . "/usr/bin/apt-get" ) )
|
( -x $tmp . "/usr/bin/apt-get" ) )
|
||||||
{
|
{
|
||||||
|
#
|
||||||
#
|
# Now run the update command.
|
||||||
# Now run the update command.
|
#
|
||||||
#
|
system( "chroot $tmp /usr/bin/apt-get update" );
|
||||||
system("chroot $tmp /usr/bin/apt-get update");
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Now upgrade
|
# Now upgrade
|
||||||
#
|
#
|
||||||
system(
|
system( "DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes" );
|
||||||
"DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "Xen image $name is not a Debian GNU/Linux image. Skipping\n";
|
print "Xen image $name is not a Debian GNU/Linux image. Skipping\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -312,6 +306,8 @@ sub updateXenImage
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Test to see if the given instance is running.
|
Test to see if the given instance is running.
|
||||||
@@ -322,24 +318,25 @@ sub updateXenImage
|
|||||||
|
|
||||||
sub xenRunning
|
sub xenRunning
|
||||||
{
|
{
|
||||||
my ($hostname) = (@_);
|
my( $hostname ) = (@_ );
|
||||||
|
|
||||||
my $running = 0;
|
my $running = 0;
|
||||||
|
|
||||||
open( CMD, "xm list 2>/dev/null |" )
|
open( CMD, "xm list 2>/dev/null |")
|
||||||
or die "Failed to run 'xm list $hostname'";
|
or die "Failed to run 'xm list $hostname'";
|
||||||
while (<CMD>)
|
while( <CMD> )
|
||||||
{
|
{
|
||||||
my $line = $_;
|
my $line = $_;
|
||||||
$running = 1 if ( $line =~ /\Q$hostname\E/ );
|
$running = 1 if ( $line =~ /\Q$hostname\E/ )
|
||||||
}
|
}
|
||||||
close(CMD);
|
close( CMD );
|
||||||
|
|
||||||
return ($running);
|
return( $running );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Read the configuration file specified.
|
Read the configuration file specified.
|
||||||
@@ -350,16 +347,16 @@ sub xenRunning
|
|||||||
|
|
||||||
sub readConfigurationFile
|
sub readConfigurationFile
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ($file) = ( @_ );
|
||||||
|
|
||||||
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
||||||
|
|
||||||
my $line = "";
|
my $line = "";
|
||||||
|
|
||||||
while ( defined( $line = <FILE> ) )
|
while (defined($line = <FILE>) )
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ( $line =~ s/\\$// )
|
if ($line =~ s/\\$//)
|
||||||
{
|
{
|
||||||
$line .= <FILE>;
|
$line .= <FILE>;
|
||||||
redo unless eof(FILE);
|
redo unless eof(FILE);
|
||||||
@@ -369,7 +366,7 @@ sub readConfigurationFile
|
|||||||
next if ( $line =~ /^([ \t]*)\#/ );
|
next if ( $line =~ /^([ \t]*)\#/ );
|
||||||
|
|
||||||
# Skip blank lines
|
# Skip blank lines
|
||||||
next if ( length($line) < 1 );
|
next if ( length( $line ) < 1 );
|
||||||
|
|
||||||
# Strip trailing comments.
|
# Strip trailing comments.
|
||||||
if ( $line =~ /(.*)\#(.*)/ )
|
if ( $line =~ /(.*)\#(.*)/ )
|
||||||
@@ -392,7 +389,6 @@ sub readConfigurationFile
|
|||||||
# command expansion?
|
# command expansion?
|
||||||
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
# store
|
# store
|
||||||
my $pre = $1;
|
my $pre = $1;
|
||||||
my $cmd = $2;
|
my $cmd = $2;
|
||||||
@@ -400,22 +396,23 @@ sub readConfigurationFile
|
|||||||
|
|
||||||
# get output
|
# get output
|
||||||
my $output = `$cmd`;
|
my $output = `$cmd`;
|
||||||
chomp($output);
|
chomp( $output );
|
||||||
|
|
||||||
# build up replacement.
|
# build up replacement.
|
||||||
$val = $pre . $output . $post;
|
$val = $pre . $output . $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store value.
|
# Store value.
|
||||||
$CONFIG{$key} = $val;
|
$CONFIG{ $key } = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Parse the arguments specified upon the command line.
|
Parse the arguments specified upon the command line.
|
||||||
@@ -433,17 +430,20 @@ sub parseCommandLineArguments
|
|||||||
# Parse options.
|
# Parse options.
|
||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
"dir=s", \$CONFIG{'dir'}, "lvm=s", \$CONFIG{'lvm'},
|
"dir=s", \$CONFIG{'dir'},
|
||||||
"evms=s", \$CONFIG{'evms'}, "help", \$HELP,
|
"lvm=s", \$CONFIG{'lvm'},
|
||||||
"manual", \$MANUAL, "version", \$VERSION
|
"evms=s", \$CONFIG{'evms'},
|
||||||
);
|
"help", \$HELP,
|
||||||
|
"manual", \$MANUAL,
|
||||||
|
"version", \$VERSION
|
||||||
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.29 $';
|
my $REVISION = '$Revision: 1.29 $';
|
||||||
|
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
@@ -468,12 +468,11 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub checkArguments
|
sub checkArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Make sure we got one and only one installation method.
|
# Make sure we got one and only one installation method.
|
||||||
#
|
#
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach my $type (qw/dir lvm evms/)
|
foreach my $type ( qw/dir lvm evms/ )
|
||||||
{
|
{
|
||||||
$count += 1 if defined( $CONFIG{$type} );
|
$count += 1 if defined( $CONFIG{$type} );
|
||||||
}
|
}
|
||||||
@@ -484,10 +483,10 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
if ( $count != 1 )
|
if ( $count != 1 )
|
||||||
{
|
{
|
||||||
print "Please select one and only one of the installation methods:\n";
|
print "Please select one and only one of the installation methods:\n";
|
||||||
print " --dir\n";
|
print " --dir\n";
|
||||||
print " --evms\n";
|
print " --evms\n";
|
||||||
print " --lvm\n";
|
print " --lvm\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ $CONFIG{'template'} = '/etc/xen-tools/xm.tmpl';
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -188,6 +189,9 @@ createXenConfig();
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Exit cleanly - any errors which have already occurred will result
|
# Exit cleanly - any errors which have already occurred will result
|
||||||
# in "exit 1".
|
# in "exit 1".
|
||||||
@@ -196,6 +200,9 @@ exit 0;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Parse the command line arguments this script was given.
|
Parse the command line arguments this script was given.
|
||||||
@@ -214,23 +221,23 @@ sub parseCommandLineArguments
|
|||||||
# Parse options.
|
# Parse options.
|
||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
"admins=s", \$ENV{'admins'},
|
"admins=s", \$ENV{'admins'},
|
||||||
"output=s", \$CONFIG{'output'},
|
"output=s", \$CONFIG{'output'},
|
||||||
"extension=s", \$CONFIG{'extension'},
|
"extension=s",\$CONFIG{'extension'},
|
||||||
"template=s", \$CONFIG{'template'},
|
"template=s", \$CONFIG{'template'},
|
||||||
"verbose", \$CONFIG{'verbose'},
|
"verbose", \$CONFIG{'verbose'},
|
||||||
"help", \$HELP,
|
"help", \$HELP,
|
||||||
"manual", \$MANUAL,
|
"manual", \$MANUAL,
|
||||||
"version", \$VERSION
|
"version", \$VERSION
|
||||||
);
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.47 $';
|
my $REVISION = '$Revision: 1.47 $';
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
$REVISION = $1;
|
$REVISION = $1;
|
||||||
@@ -253,11 +260,10 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub checkArguments
|
sub checkArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# We require an output location.
|
# We require an output location.
|
||||||
#
|
#
|
||||||
if ( !defined( $CONFIG{'output'} ) )
|
if ( ! defined( $CONFIG{'output'} ) )
|
||||||
{
|
{
|
||||||
print "The '--output' argument is mandatory\n";
|
print "The '--output' argument is mandatory\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -266,10 +272,9 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
# The output location should be a directory which exists.
|
# The output location should be a directory which exists.
|
||||||
#
|
#
|
||||||
if ( !-d $CONFIG{'output'} )
|
if ( ! -d $CONFIG{'output'} )
|
||||||
{
|
{
|
||||||
print
|
print "The output directory we've been given, $CONFIG{'output'}, doesnt exist\n";
|
||||||
"The output directory we've been given, $CONFIG{'output'}, doesnt exist\n";
|
|
||||||
print "Aborting\n";
|
print "Aborting\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@@ -279,10 +284,9 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
if ( defined( $CONFIG{'template'} ) )
|
if ( defined( $CONFIG{'template'} ) )
|
||||||
{
|
{
|
||||||
if ( !-e $CONFIG{'template'} )
|
if ( ! -e $CONFIG{'template'} )
|
||||||
{
|
{
|
||||||
print
|
print "The specified template file, $CONFIG{'template'} does not exist.\n";
|
||||||
"The specified template file, $CONFIG{'template'} does not exist.\n";
|
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,20 +310,19 @@ sub importPartitionsFromEnvironment
|
|||||||
{
|
{
|
||||||
@PARTITIONS = ();
|
@PARTITIONS = ();
|
||||||
|
|
||||||
for ( my $i = 1 ; $i <= $ENV{'NUMPARTITIONS'} ; $i++ )
|
for (my $i=1; $i <= $ENV{'NUMPARTITIONS'}; $i++)
|
||||||
{
|
{
|
||||||
my @parts = split( /:/, $ENV{'PARTITION' . $i}, 7 );
|
my @parts = split(/:/, $ENV{'PARTITION' . $i}, 7);
|
||||||
push(
|
push( @PARTITIONS,
|
||||||
@PARTITIONS,
|
{
|
||||||
{
|
'name' => $parts[0],
|
||||||
'name' => $parts[0],
|
'size' => $parts[1],
|
||||||
'size' => $parts[1],
|
'type' => $parts[2],
|
||||||
'type' => $parts[2],
|
'mountpoint' => $parts[3],
|
||||||
'mountpoint' => $parts[3],
|
'options' => $parts[4],
|
||||||
'options' => $parts[4],
|
'imagetype' => $parts[5],
|
||||||
'imagetype' => $parts[5],
|
'image' => $parts[6]
|
||||||
'image' => $parts[6]
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +341,6 @@ sub importPartitionsFromEnvironment
|
|||||||
|
|
||||||
sub createXenConfig
|
sub createXenConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# The output file we're going to process.
|
# The output file we're going to process.
|
||||||
#
|
#
|
||||||
@@ -414,7 +416,7 @@ sub createXenConfig
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$ENV{'swap_vbd'} = undef;
|
$ENV{'swap_vbd'} = undef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -436,7 +438,7 @@ sub createXenConfig
|
|||||||
# made available to our template file.
|
# made available to our template file.
|
||||||
#
|
#
|
||||||
my %vars;
|
my %vars;
|
||||||
foreach my $key ( sort keys %ENV )
|
foreach my $key (sort keys %ENV )
|
||||||
{
|
{
|
||||||
$vars{$key} = $ENV{$key};
|
$vars{$key} = $ENV{$key};
|
||||||
}
|
}
|
||||||
@@ -455,9 +457,9 @@ sub createXenConfig
|
|||||||
#
|
#
|
||||||
# Write the output of processing the template file, if it succeeds.
|
# Write the output of processing the template file, if it succeeds.
|
||||||
#
|
#
|
||||||
if ( defined $result )
|
if (defined $result)
|
||||||
{
|
{
|
||||||
print FILE $result;
|
print FILE $result ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -467,12 +469,13 @@ sub createXenConfig
|
|||||||
#
|
#
|
||||||
# Close the output file.
|
# Close the output file.
|
||||||
#
|
#
|
||||||
close(FILE);
|
close( FILE );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
This routine is designed to ensure that any users specified with
|
This routine is designed to ensure that any users specified with
|
||||||
@@ -484,7 +487,6 @@ sub createXenConfig
|
|||||||
|
|
||||||
sub setupAdminUsers
|
sub setupAdminUsers
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we're not root we can't modify users.
|
# If we're not root we can't modify users.
|
||||||
#
|
#
|
||||||
@@ -493,17 +495,16 @@ sub setupAdminUsers
|
|||||||
#
|
#
|
||||||
# If we don't have a sudoers file then we'll also ignore this.
|
# If we don't have a sudoers file then we'll also ignore this.
|
||||||
#
|
#
|
||||||
return if ( !-e "/etc/sudoers" );
|
return if ( ! -e "/etc/sudoers" );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find the path to the xen-login-shell
|
# Find the path to the xen-login-shell
|
||||||
#
|
#
|
||||||
my $shell = undef;
|
my $shell = undef;
|
||||||
$shell = "/usr/bin/xen-login-shell" if ( -x "/usr/bin/xen-login-shell" );
|
$shell = "/usr/bin/xen-login-shell" if ( -x "/usr/bin/xen-login-shell" );
|
||||||
$shell = "/usr/local/bin/xen-login-shell"
|
$shell = "/usr/local/bin/xen-login-shell" if ( -x "/usr/bin/local/xen-login-shell" );
|
||||||
if ( -x "/usr/bin/local/xen-login-shell" );
|
|
||||||
|
|
||||||
return if ( !defined($shell) );
|
return if ( !defined( $shell ) );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -512,7 +513,6 @@ sub setupAdminUsers
|
|||||||
#
|
#
|
||||||
foreach my $user ( split( /,/, $ENV{'admins'} ) )
|
foreach my $user ( split( /,/, $ENV{'admins'} ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
# Strip leading and trailing whitespace.
|
# Strip leading and trailing whitespace.
|
||||||
$user =~ s/^\s+//;
|
$user =~ s/^\s+//;
|
||||||
$user =~ s/\s+$//;
|
$user =~ s/\s+$//;
|
||||||
@@ -523,14 +523,12 @@ sub setupAdminUsers
|
|||||||
# Does the user exist?
|
# Does the user exist?
|
||||||
if ( getpwnam($user) )
|
if ( getpwnam($user) )
|
||||||
{
|
{
|
||||||
|
|
||||||
# Change shell.
|
# Change shell.
|
||||||
$CONFIG{'verbose'} && print "Changing shell for $user: $shell\n";
|
$CONFIG{'verbose'} && print "Changing shell for $user: $shell\n";
|
||||||
system( "chsh", "-s", $shell, $user );
|
system( "chsh", "-s", $shell, $user );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
# Add a new user.
|
# Add a new user.
|
||||||
$CONFIG{'verbose'} && print "Adding new user: $user\n";
|
$CONFIG{'verbose'} && print "Adding new user: $user\n";
|
||||||
system( "useradd", "-s", $shell, $user );
|
system( "useradd", "-s", $shell, $user );
|
||||||
@@ -539,11 +537,9 @@ sub setupAdminUsers
|
|||||||
#
|
#
|
||||||
# Add the entry to /etc/sudoers.
|
# Add the entry to /etc/sudoers.
|
||||||
#
|
#
|
||||||
open( SUDOERS, ">>", "/etc/sudoers" )
|
open( SUDOERS, ">>", "/etc/sudoers" ) or warn "Failed to add user to sudoers file : $user - $!";
|
||||||
or warn "Failed to add user to sudoers file : $user - $!";
|
print SUDOERS "$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n";
|
||||||
print SUDOERS
|
close( SUDOERS );
|
||||||
"$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n";
|
|
||||||
close(SUDOERS);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ my %CONFIG;
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -127,6 +128,9 @@ exit 0;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Parse the command line arguments this script was given.
|
Parse the command line arguments this script was given.
|
||||||
@@ -145,28 +149,28 @@ sub parseCommandLineArguments
|
|||||||
# Parse options.
|
# Parse options.
|
||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
"location=s", \$CONFIG{'location'},
|
"location=s", \$CONFIG{'location'},
|
||||||
"dist=s", \$CONFIG{'dist'},
|
"dist=s", \$CONFIG{'dist'},
|
||||||
"verbose", \$CONFIG{'verbose'},
|
"verbose", \$CONFIG{'verbose'},
|
||||||
"help", \$HELP,
|
"help", \$HELP,
|
||||||
"manual", \$MANUAL,
|
"manual", \$MANUAL,
|
||||||
"version", \$VERSION
|
"version", \$VERSION
|
||||||
);
|
);
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.33 $';
|
my $REVISION = '$Revision: 1.33 $';
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
$REVISION = $1;
|
$REVISION = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "xt-customize-image release $RELEASE - CVS: $REVISION\n";
|
print "xt-customize-image release $RELEASE - CVS: $REVISION\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,11 +186,10 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub checkArguments
|
sub checkArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# We require a location.
|
# We require a location.
|
||||||
#
|
#
|
||||||
if ( !defined( $CONFIG{'location'} ) )
|
if ( ! defined( $CONFIG{'location'} ) )
|
||||||
{
|
{
|
||||||
print "The '--location' argument is mandatory\n";
|
print "The '--location' argument is mandatory\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -196,7 +199,7 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
# Test that the location we've been given exists
|
# Test that the location we've been given exists
|
||||||
#
|
#
|
||||||
if ( !-d $CONFIG{'location'} )
|
if ( ! -d $CONFIG{'location'} )
|
||||||
{
|
{
|
||||||
print "The installation directory we've been given doesn't exist\n";
|
print "The installation directory we've been given doesn't exist\n";
|
||||||
print "We tried to use : $CONFIG{'location'}\n";
|
print "We tried to use : $CONFIG{'location'}\n";
|
||||||
@@ -207,7 +210,7 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
# We require a distribution name.
|
# We require a distribution name.
|
||||||
#
|
#
|
||||||
if ( !defined( $CONFIG{'dist'} ) )
|
if ( ! defined( $CONFIG{'dist'} ) )
|
||||||
{
|
{
|
||||||
print "The '--dist' argument is mandatory\n";
|
print "The '--dist' argument is mandatory\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -221,9 +224,9 @@ sub checkArguments
|
|||||||
# If there are no scripts then we clearly cannot
|
# If there are no scripts then we clearly cannot
|
||||||
# customise it!
|
# customise it!
|
||||||
#
|
#
|
||||||
my $dir = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d";
|
my $dir = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d";
|
||||||
|
|
||||||
if ( !-d $dir )
|
if ( ! -d $dir )
|
||||||
{
|
{
|
||||||
print <<E_OR;
|
print <<E_OR;
|
||||||
|
|
||||||
@@ -259,11 +262,10 @@ E_OR
|
|||||||
|
|
||||||
sub runDistributionHooks
|
sub runDistributionHooks
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Hook directory.
|
# Hook directory.
|
||||||
#
|
#
|
||||||
my $hooks = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d/";
|
my $hooks = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d/";
|
||||||
|
|
||||||
#
|
#
|
||||||
# Installation prefix
|
# Installation prefix
|
||||||
@@ -288,7 +290,6 @@ sub runDistributionHooks
|
|||||||
#
|
#
|
||||||
foreach my $file ( sort( glob( $hooks . "*" ) ) )
|
foreach my $file ( sort( glob( $hooks . "*" ) ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
# skip files that end with .dpkg-new, .dpkg-old or '~'
|
# skip files that end with .dpkg-new, .dpkg-old or '~'
|
||||||
next if ( $file =~ /\.dpkg-(new|old)/ );
|
next if ( $file =~ /\.dpkg-(new|old)/ );
|
||||||
next if ( $file =~ /~$/ );
|
next if ( $file =~ /~$/ );
|
||||||
@@ -298,7 +299,6 @@ sub runDistributionHooks
|
|||||||
#
|
#
|
||||||
if ( ( -x $file ) && ( -f $file ) )
|
if ( ( -x $file ) && ( -f $file ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Just display the name - no need to see the full path.
|
# Just display the name - no need to see the full path.
|
||||||
#
|
#
|
||||||
@@ -321,14 +321,14 @@ sub runDistributionHooks
|
|||||||
{
|
{
|
||||||
print "Running hook $name ['$cmd']\n";
|
print "Running hook $name ['$cmd']\n";
|
||||||
print "--\n";
|
print "--\n";
|
||||||
system($cmd );
|
system( $cmd );
|
||||||
print "--\n";
|
print "--\n";
|
||||||
print "Done\n\n";
|
print "Done\n\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "Running hook $name\n";
|
print "Running hook $name\n";
|
||||||
system($cmd );
|
system( $cmd );
|
||||||
print "hook $name: done.\n";
|
print "hook $name: done.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ my %CONFIG;
|
|||||||
#
|
#
|
||||||
# Release number.
|
# Release number.
|
||||||
#
|
#
|
||||||
my $RELEASE = '4.1';
|
my $RELEASE = '3.9';
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -127,41 +127,50 @@ my $RELEASE = '4.1';
|
|||||||
# needDirectory Defined if we need an install-source directory specified.
|
# needDirectory Defined if we need an install-source directory specified.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
my %dispatch = (
|
my %dispatch =
|
||||||
"copy" => {
|
(
|
||||||
sub => \&do_copy,
|
"copy" =>
|
||||||
needBinary => "/bin/cp",
|
{
|
||||||
needDirectory => 1,
|
sub => \&do_copy,
|
||||||
},
|
needBinary => "/bin/cp",
|
||||||
"debootstrap" => {
|
needDirectory => 1,
|
||||||
sub => \&do_debootstrap,
|
},
|
||||||
needBinary => "/usr/sbin/debootstrap",
|
"debootstrap" =>
|
||||||
},
|
{
|
||||||
"image-server" => {
|
sub => \&do_debootstrap,
|
||||||
sub => \&do_image_server,
|
needBinary => "/usr/sbin/debootstrap",
|
||||||
needURL => 1,
|
},
|
||||||
},
|
"image-server" =>
|
||||||
"rinse" => {
|
{
|
||||||
sub => \&do_rinse,
|
sub => \&do_image_server,
|
||||||
needBinary => "/usr/bin/rinse",
|
needURL => 1,
|
||||||
},
|
},
|
||||||
"rpmstrap" => {
|
"rinse" =>
|
||||||
sub => \&do_rpmstrap,
|
{
|
||||||
needBinary => "/usr/bin/rpmstrap",
|
sub => \&do_rinse,
|
||||||
},
|
needBinary => "/usr/bin/rinse",
|
||||||
"tar" => {
|
},
|
||||||
sub => \&do_tar,
|
"rpmstrap" =>
|
||||||
needBinary => "/bin/tar",
|
{
|
||||||
needFile => 1,
|
sub => \&do_rpmstrap,
|
||||||
}
|
needBinary => "/usr/bin/rpmstrap",
|
||||||
|
},
|
||||||
|
"tar" =>
|
||||||
|
{
|
||||||
|
sub => \&do_tar,
|
||||||
|
needBinary => "/bin/tar",
|
||||||
|
needFile => 1,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read the global configuration file.
|
# Read the global configuration file.
|
||||||
#
|
#
|
||||||
readConfigurationFile("/etc/xen-tools/xen-tools.conf");
|
readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -184,7 +193,7 @@ if ( $CONFIG{'config'} )
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Read the file, if it exists.
|
# Read the file, if it exists.
|
||||||
readConfigurationFile($path) if ( -e $path );
|
readConfigurationFile( $path ) if ( -e $path );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,65 +206,59 @@ checkArguments();
|
|||||||
#
|
#
|
||||||
# Now lookup our installation type and dispatch control to it.
|
# Now lookup our installation type and dispatch control to it.
|
||||||
#
|
#
|
||||||
if ( defined( $CONFIG{'install-method'} )
|
if ( defined( $CONFIG{'install-method'} ) &&
|
||||||
&& length( $CONFIG{'install-method'} ) )
|
length( $CONFIG{'install-method'} ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get the entry from the dispatch table.
|
# Get the entry from the dispatch table.
|
||||||
#
|
#
|
||||||
my $installer = $dispatch{lc( $CONFIG{'install-method'} )};
|
my $installer = $dispatch{ lc($CONFIG{'install-method'}) };
|
||||||
|
|
||||||
if ( defined($installer) )
|
if ( defined( $installer ) )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we found it.
|
# If we found it.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Do we need to test for a binary.
|
# Do we need to test for a binary.
|
||||||
if ( ( $installer->{'needBinary'} )
|
if ( ( $installer->{'needBinary'} ) &&
|
||||||
&& ( !-x $installer->{'needBinary'} ) )
|
( ! -x $installer->{'needBinary'} ) )
|
||||||
{
|
{
|
||||||
print
|
print "The following required binary for the installation was not found\n";
|
||||||
"The following required binary for the installation was not found\n";
|
|
||||||
print "\t" . $installer->{'needBinary'} . "\n";
|
print "\t" . $installer->{'needBinary'} . "\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do we need a directory specified as the installation source?
|
# Do we need a directory specified as the installation source?
|
||||||
if ( ( $installer->{'needDirectory'} )
|
if ( ( $installer->{'needDirectory'} ) &&
|
||||||
&& ( !$CONFIG{'install-source'} || !-d $CONFIG{'install-source'} ) )
|
( ! $CONFIG{'install-source'} || ! -d $CONFIG{'install-source'} ) )
|
||||||
{
|
{
|
||||||
print "Please specify the source directory with --install-source\n";
|
print "Please specify the source directory with --install-source\n";
|
||||||
if ( $CONFIG{'install-source'} )
|
if ( $CONFIG{'install-source'} )
|
||||||
{
|
{
|
||||||
print
|
print "The specified directory $CONFIG{'install-source'} does not exist.\n";
|
||||||
"The specified directory $CONFIG{'install-source'} does not exist.\n";
|
|
||||||
}
|
}
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do we need a file specified as the installation source?
|
# Do we need a file specified as the installation source?
|
||||||
if ( ( $installer->{'needFile'} )
|
if ( ( $installer->{'needFile'} ) &&
|
||||||
&& ( !$CONFIG{'install-source'} || !-e $CONFIG{'install-source'} ) )
|
( ! $CONFIG{'install-source'} || ! -e $CONFIG{'install-source'} ) )
|
||||||
{
|
{
|
||||||
print "Please specify the source file with --install-source\n";
|
print "Please specify the source file with --install-source\n";
|
||||||
|
|
||||||
if ( $CONFIG{'install-source'} )
|
if ( $CONFIG{'install-source'} )
|
||||||
{
|
{
|
||||||
print
|
print "The specified file $CONFIG{'install-source'} does not exist.\n";
|
||||||
"The specified file $CONFIG{'install-source'} does not exist.\n";
|
|
||||||
}
|
}
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do we need an URL specified as the installation source?
|
# Do we need an URL specified as the installation source?
|
||||||
if (
|
if ( ( $installer->{'needURL'} ) &&
|
||||||
( $installer->{'needURL'} )
|
( ! $CONFIG{'install-source'} ||
|
||||||
&& ( !$CONFIG{'install-source'}
|
( $CONFIG{'install-source'} !~ /^http/i ) ) )
|
||||||
|| ( $CONFIG{'install-source'} !~ /^http/i ) )
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
print "Please specify the image server URL with --install-source\n";
|
print "Please specify the image server URL with --install-source\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -273,9 +276,9 @@ if ( defined( $CONFIG{'install-method'} )
|
|||||||
#
|
#
|
||||||
# Test that we have some "standard" files present.
|
# Test that we have some "standard" files present.
|
||||||
#
|
#
|
||||||
foreach my $file (qw( /bin/ls /bin/cp ))
|
foreach my $file ( qw( /bin/ls /bin/cp ) )
|
||||||
{
|
{
|
||||||
if ( !-x $CONFIG{'location'} . $file )
|
if ( ! -x $CONFIG{'location'} . $file )
|
||||||
{
|
{
|
||||||
print "The installation of the new system has failed.\n";
|
print "The installation of the new system has failed.\n";
|
||||||
print "\n";
|
print "\n";
|
||||||
@@ -303,6 +306,10 @@ else
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Read the specified configuration file, and update our global configuration
|
Read the specified configuration file, and update our global configuration
|
||||||
@@ -314,20 +321,20 @@ else
|
|||||||
|
|
||||||
sub readConfigurationFile
|
sub readConfigurationFile
|
||||||
{
|
{
|
||||||
my ($file) = (@_);
|
my ($file) = ( @_ );
|
||||||
|
|
||||||
# Don't read the file if it doesn't exist.
|
# Don't read the file if it doesn't exist.
|
||||||
return if ( !-e $file );
|
return if ( ! -e $file );
|
||||||
|
|
||||||
|
|
||||||
my $line = "";
|
my $line = "";
|
||||||
|
|
||||||
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
|
||||||
|
|
||||||
while ( defined( $line = <FILE> ) )
|
while (defined($line = <FILE>) )
|
||||||
{
|
{
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ( $line =~ s/\\$// )
|
if ($line =~ s/\\$//)
|
||||||
{
|
{
|
||||||
$line .= <FILE>;
|
$line .= <FILE>;
|
||||||
redo unless eof(FILE);
|
redo unless eof(FILE);
|
||||||
@@ -337,7 +344,7 @@ sub readConfigurationFile
|
|||||||
next if ( $line =~ /^([ \t]*)\#/ );
|
next if ( $line =~ /^([ \t]*)\#/ );
|
||||||
|
|
||||||
# Skip blank lines
|
# Skip blank lines
|
||||||
next if ( length($line) < 1 );
|
next if ( length( $line ) < 1 );
|
||||||
|
|
||||||
# Strip trailing comments.
|
# Strip trailing comments.
|
||||||
if ( $line =~ /(.*)\#(.*)/ )
|
if ( $line =~ /(.*)\#(.*)/ )
|
||||||
@@ -360,7 +367,6 @@ sub readConfigurationFile
|
|||||||
# command expansion?
|
# command expansion?
|
||||||
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
if ( $val =~ /(.*)`([^`]+)`(.*)/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
# store
|
# store
|
||||||
my $pre = $1;
|
my $pre = $1;
|
||||||
my $cmd = $2;
|
my $cmd = $2;
|
||||||
@@ -368,18 +374,18 @@ sub readConfigurationFile
|
|||||||
|
|
||||||
# get output
|
# get output
|
||||||
my $output = `$cmd`;
|
my $output = `$cmd`;
|
||||||
chomp($output);
|
chomp( $output );
|
||||||
|
|
||||||
# build up replacement.
|
# build up replacement.
|
||||||
$val = $pre . $output . $post;
|
$val = $pre . $output . $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Store value.
|
# Store value.
|
||||||
$CONFIG{$key} = $val;
|
$CONFIG{ $key } = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(FILE);
|
close( FILE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -402,36 +408,35 @@ sub parseCommandLineArguments
|
|||||||
# Parse options.
|
# Parse options.
|
||||||
#
|
#
|
||||||
GetOptions(
|
GetOptions(
|
||||||
|
# Mandatory
|
||||||
|
"location=s", \$CONFIG{'location'},
|
||||||
|
"dist=s", \$CONFIG{'dist'},
|
||||||
|
"hostname=s", \$CONFIG{'hostname'},
|
||||||
|
|
||||||
# Mandatory
|
# Installation method
|
||||||
"location=s", \$CONFIG{'location'},
|
"install-method=s", \$CONFIG{'install-method'},
|
||||||
"dist=s", \$CONFIG{'dist'},
|
"install-source=s", \$CONFIG{'install-source'},
|
||||||
"hostname=s", \$CONFIG{'hostname'},
|
|
||||||
|
|
||||||
# Installation method
|
# Misc
|
||||||
"install-method=s", \$CONFIG{'install-method'},
|
"arch=s", \$CONFIG{'arch'},
|
||||||
"install-source=s", \$CONFIG{'install-source'},
|
"cache=s", \$CONFIG{'cache'},
|
||||||
|
"config=s", \$CONFIG{'config'},
|
||||||
|
"mirror=s", \$CONFIG{'mirror'},
|
||||||
|
|
||||||
# Misc
|
# Help.
|
||||||
"arch=s", \$CONFIG{'arch'},
|
"verbose", \$CONFIG{'verbose'},
|
||||||
"cache=s", \$CONFIG{'cache'},
|
"help", \$HELP,
|
||||||
"config=s", \$CONFIG{'config'},
|
"manual", \$MANUAL,
|
||||||
"mirror=s", \$CONFIG{'mirror'},
|
"version", \$VERSION
|
||||||
|
);
|
||||||
# Help.
|
|
||||||
"verbose", \$CONFIG{'verbose'},
|
|
||||||
"help", \$HELP,
|
|
||||||
"manual", \$MANUAL,
|
|
||||||
"version", \$VERSION
|
|
||||||
);
|
|
||||||
|
|
||||||
pod2usage(1) if $HELP;
|
pod2usage(1) if $HELP;
|
||||||
pod2usage( -verbose => 2 ) if $MANUAL;
|
pod2usage(-verbose => 2 ) if $MANUAL;
|
||||||
|
|
||||||
|
|
||||||
if ($VERSION)
|
if ( $VERSION )
|
||||||
{
|
{
|
||||||
my $REVISION = '$Revision: 1.65 $';
|
my $REVISION = '$Revision: 1.65 $';
|
||||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||||
{
|
{
|
||||||
$REVISION = $1;
|
$REVISION = $1;
|
||||||
@@ -454,11 +459,10 @@ sub parseCommandLineArguments
|
|||||||
|
|
||||||
sub checkArguments
|
sub checkArguments
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# We require a location.
|
# We require a location.
|
||||||
#
|
#
|
||||||
if ( !defined( $CONFIG{'location'} ) )
|
if ( ! defined( $CONFIG{'location'} ) )
|
||||||
{
|
{
|
||||||
print "The '--location' argument is mandatory\n";
|
print "The '--location' argument is mandatory\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -468,7 +472,7 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
# Test that the location we've been given exists
|
# Test that the location we've been given exists
|
||||||
#
|
#
|
||||||
if ( !-d $CONFIG{'location'} )
|
if ( ! -d $CONFIG{'location'} )
|
||||||
{
|
{
|
||||||
print "The installation directory we've been given doesn't exist\n";
|
print "The installation directory we've been given doesn't exist\n";
|
||||||
print "We tried to use : $CONFIG{'location'}\n";
|
print "We tried to use : $CONFIG{'location'}\n";
|
||||||
@@ -479,7 +483,7 @@ sub checkArguments
|
|||||||
#
|
#
|
||||||
# We require a distribution name.
|
# We require a distribution name.
|
||||||
#
|
#
|
||||||
if ( !defined( $CONFIG{'dist'} ) )
|
if ( ! defined( $CONFIG{'dist'} ) )
|
||||||
{
|
{
|
||||||
print "The '--dist' argument is mandatory\n";
|
print "The '--dist' argument is mandatory\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@@ -493,9 +497,9 @@ sub checkArguments
|
|||||||
# If there are no scripts then we clearly cannot
|
# If there are no scripts then we clearly cannot
|
||||||
# customise it!
|
# customise it!
|
||||||
#
|
#
|
||||||
my $dir = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d";
|
my $dir = "/usr/lib/xen-tools/" . $CONFIG{'dist'} . ".d";
|
||||||
|
|
||||||
if ( !-d $dir )
|
if ( ! -d $dir )
|
||||||
{
|
{
|
||||||
print <<E_OR;
|
print <<E_OR;
|
||||||
|
|
||||||
@@ -520,8 +524,7 @@ E_OR
|
|||||||
{
|
{
|
||||||
foreach my $recognised ( keys %dispatch )
|
foreach my $recognised ( keys %dispatch )
|
||||||
{
|
{
|
||||||
$valid = 1
|
$valid = 1 if ( lc($CONFIG{'install-method'}) eq lc($recognised) );
|
||||||
if ( lc( $CONFIG{'install-method'} ) eq lc($recognised) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -549,6 +552,7 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
A utility method to run a system command. We will capture the return
|
A utility method to run a system command. We will capture the return
|
||||||
@@ -562,7 +566,7 @@ EOF
|
|||||||
|
|
||||||
sub runCommand
|
sub runCommand
|
||||||
{
|
{
|
||||||
my ($cmd) = (@_);
|
my ( $cmd ) = (@_ );
|
||||||
|
|
||||||
#
|
#
|
||||||
# Command start.
|
# Command start.
|
||||||
@@ -591,11 +595,12 @@ sub runCommand
|
|||||||
#
|
#
|
||||||
$CONFIG{'verbose'} && print "Finished : $cmd\n";
|
$CONFIG{'verbose'} && print "Finished : $cmd\n";
|
||||||
|
|
||||||
return ($output);
|
return( $output );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
This function will copy all the .deb files from one directory
|
This function will copy all the .deb files from one directory
|
||||||
@@ -608,7 +613,7 @@ sub runCommand
|
|||||||
|
|
||||||
sub copyDebFiles
|
sub copyDebFiles
|
||||||
{
|
{
|
||||||
my ( $source, $dest ) = (@_);
|
my ( $source, $dest ) = ( @_ );
|
||||||
|
|
||||||
print "Copying files from $source -> $dest\n";
|
print "Copying files from $source -> $dest\n";
|
||||||
|
|
||||||
@@ -626,7 +631,7 @@ sub copyDebFiles
|
|||||||
#
|
#
|
||||||
# Only copy if the file doesn't already exist.
|
# Only copy if the file doesn't already exist.
|
||||||
#
|
#
|
||||||
if ( !( -e $dest . "/" . $name ) )
|
if ( ! ( -e $dest . "/" . $name ) )
|
||||||
{
|
{
|
||||||
File::Copy::cp( $file, $dest );
|
File::Copy::cp( $file, $dest );
|
||||||
}
|
}
|
||||||
@@ -637,6 +642,8 @@ sub copyDebFiles
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
#
|
#
|
||||||
# Installation functions follow.
|
# Installation functions follow.
|
||||||
@@ -645,6 +652,7 @@ sub copyDebFiles
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Install a new image of a distribution using `cp`.
|
Install a new image of a distribution using `cp`.
|
||||||
@@ -655,15 +663,14 @@ sub copyDebFiles
|
|||||||
|
|
||||||
sub do_copy
|
sub do_copy
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find the copy command to run from the configuration file.
|
# Find the copy command to run from the configuration file.
|
||||||
#
|
#
|
||||||
my $cmd = $CONFIG{'copy-cmd'};
|
my $cmd = $CONFIG{'copy-cmd'} ;
|
||||||
if ( !defined($cmd) )
|
if ( !defined( $cmd ) )
|
||||||
{
|
{
|
||||||
print "Falling back to default copy command\n";
|
print "Falling back to default copy command\n";
|
||||||
$cmd = '/bin/cp -a $src/* $dest'; # Note: single quotes.
|
$cmd = '/bin/cp -a $src/* $dest'; # Note: single quotes.
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -675,11 +682,12 @@ sub do_copy
|
|||||||
#
|
#
|
||||||
# Run the copy command.
|
# Run the copy command.
|
||||||
#
|
#
|
||||||
runCommand($cmd);
|
runCommand( $cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Install a new image of Debian using 'debootstrap'.
|
Install a new image of Debian using 'debootstrap'.
|
||||||
@@ -690,13 +698,12 @@ sub do_copy
|
|||||||
|
|
||||||
sub do_debootstrap
|
sub do_debootstrap
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# The command is a little configurable - mostly to allow you
|
# The command is a little configurable - mostly to allow you
|
||||||
# to use cdebootstrap.
|
# to use cdebootstrap.
|
||||||
#
|
#
|
||||||
my $cmd = $CONFIG{'debootstrap-cmd'};
|
my $cmd = $CONFIG{'debootstrap-cmd'} ;
|
||||||
if ( !defined($cmd) )
|
if ( !defined( $cmd ) )
|
||||||
{
|
{
|
||||||
print "Falling back to default debootstrap command\n";
|
print "Falling back to default debootstrap command\n";
|
||||||
$cmd = '/usr/sbin/debootstrap';
|
$cmd = '/usr/sbin/debootstrap';
|
||||||
@@ -710,10 +717,9 @@ sub do_debootstrap
|
|||||||
if ( $CONFIG{'cache'} eq "yes" )
|
if ( $CONFIG{'cache'} eq "yes" )
|
||||||
{
|
{
|
||||||
print "\nCopying files from host to image.\n";
|
print "\nCopying files from host to image.\n";
|
||||||
runCommand("mkdir -p $CONFIG{'location'}/var/cache/apt/archives");
|
runCommand( "mkdir -p $CONFIG{'location'}/var/cache/apt/archives" );
|
||||||
copyDebFiles( "/var/cache/apt/archives",
|
copyDebFiles( "/var/cache/apt/archives", "$CONFIG{'location'}/var/cache/apt/archives" );
|
||||||
"$CONFIG{'location'}/var/cache/apt/archives" );
|
print( "Done\n" );
|
||||||
print("Done\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -730,20 +736,19 @@ sub do_debootstrap
|
|||||||
#
|
#
|
||||||
if ( $CONFIG{'arch'} )
|
if ( $CONFIG{'arch'} )
|
||||||
{
|
{
|
||||||
$EXTRA .= " --arch $CONFIG{'arch'}";
|
$EXTRA .= " --arch $CONFIG{'arch'}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# This is the command we'll run
|
# This is the command we'll run
|
||||||
#
|
#
|
||||||
my $command =
|
my $command = "$cmd $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $CONFIG{'mirror'}";
|
||||||
"$cmd $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $CONFIG{'mirror'}";
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Run the command.
|
# Run the command.
|
||||||
#
|
#
|
||||||
runCommand($command);
|
runCommand( $command );
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -755,7 +760,7 @@ sub do_debootstrap
|
|||||||
print "\nCopying files from new installation to host.\n";
|
print "\nCopying files from new installation to host.\n";
|
||||||
copyDebFiles( "$CONFIG{'location'}/var/cache/apt/archives",
|
copyDebFiles( "$CONFIG{'location'}/var/cache/apt/archives",
|
||||||
"/var/cache/apt/archives" );
|
"/var/cache/apt/archives" );
|
||||||
print("Done\n");
|
print( "Done\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -763,6 +768,7 @@ sub do_debootstrap
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Install a system using the image-server.
|
Install a system using the image-server.
|
||||||
@@ -775,7 +781,6 @@ sub do_debootstrap
|
|||||||
|
|
||||||
sub do_image_server
|
sub do_image_server
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Load the modules we require.
|
# Load the modules we require.
|
||||||
#
|
#
|
||||||
@@ -788,8 +793,8 @@ sub do_image_server
|
|||||||
# which users will not require for the typical installation
|
# which users will not require for the typical installation
|
||||||
# method(s).
|
# method(s).
|
||||||
#
|
#
|
||||||
eval($test);
|
eval( $test );
|
||||||
if ($@)
|
if ( $@ )
|
||||||
{
|
{
|
||||||
die "The module LDP::UserAgent wasn't found...\n";
|
die "The module LDP::UserAgent wasn't found...\n";
|
||||||
}
|
}
|
||||||
@@ -813,16 +818,15 @@ sub do_image_server
|
|||||||
#
|
#
|
||||||
$request .= "&arch=amd64";
|
$request .= "&arch=amd64";
|
||||||
$request .= "&root_device=/dev/sda";
|
$request .= "&root_device=/dev/sda";
|
||||||
$request .= "&ip1=" . $ENV{'ip1'};
|
$request .= "&ip1=" . $ENV{'ip1'};
|
||||||
$request .= "&dist=" . CGI::escapeHTML( $CONFIG{'dist'} );
|
$request .= "&dist=" . CGI::escapeHTML( $CONFIG{'dist'} );
|
||||||
$request .= "&hostname=" . CGI::escapeHTML( $CONFIG{'hostname'} );
|
$request .= "&hostname=" . CGI::escapeHTML( $CONFIG{'hostname'} );
|
||||||
|
|
||||||
#
|
#
|
||||||
# We only care about some keys
|
# We only care about some keys
|
||||||
#
|
#
|
||||||
foreach my $k (qw/ dhcp broadcast gateway netmask /)
|
foreach my $k ( qw/ dhcp broadcast gateway netmask / )
|
||||||
{
|
{
|
||||||
|
|
||||||
# Skip values which aren't defined.
|
# Skip values which aren't defined.
|
||||||
next unless defined $ENV{$k};
|
next unless defined $ENV{$k};
|
||||||
|
|
||||||
@@ -844,8 +848,8 @@ sub do_image_server
|
|||||||
#
|
#
|
||||||
# Do the creation step
|
# Do the creation step
|
||||||
#
|
#
|
||||||
my $response = $ua->get($request);
|
my $response = $ua->get( $request );
|
||||||
if ( $response->is_success )
|
if ($response->is_success)
|
||||||
{
|
{
|
||||||
my $content = $response->content;
|
my $content = $response->content;
|
||||||
|
|
||||||
@@ -853,74 +857,70 @@ sub do_image_server
|
|||||||
{
|
{
|
||||||
my $session = $1;
|
my $session = $1;
|
||||||
my $new = $CONFIG{'install-source'};
|
my $new = $CONFIG{'install-source'};
|
||||||
$new .= "/fetch.cgi?session=$session";
|
$new .= "/fetch.cgi?session=$session";
|
||||||
my $attempt = 1;
|
my $attempt = 1;
|
||||||
|
|
||||||
# Make sure we don't wait indefinitely.
|
# Make sure we don't wait indefinitely.
|
||||||
while ( $attempt < $attempts )
|
while( $attempt < $attempts )
|
||||||
{
|
{
|
||||||
$CONFIG{'verbose'} && print "Request: [$attempt/$attempts]\n";
|
$CONFIG{'verbose'} && print "Request: [$attempt/$attempts]\n";
|
||||||
|
|
||||||
#
|
#
|
||||||
# Make a request to see if our tar file is ready yet.
|
# Make a request to see if our tar file is ready yet.
|
||||||
#
|
#
|
||||||
$response = $ua->head($new);
|
$response = $ua->head( $new );
|
||||||
if ( $response->is_success )
|
if ( $response->is_success )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get the headers
|
# Get the headers
|
||||||
#
|
#
|
||||||
my $header = $response->headers();
|
my $header = $response->headers();
|
||||||
my $type = $header->{'content-type'};
|
my $type = $header->{'content-type'};
|
||||||
|
|
||||||
#
|
#
|
||||||
# OK our file is correct.
|
# OK our file is correct.
|
||||||
#
|
#
|
||||||
if ( $type =~ /tar/ )
|
if ( $type =~ /tar/ )
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Download it to the installation root.
|
# Download it to the installation root.
|
||||||
#
|
#
|
||||||
$ua->get( $new,
|
$ua->get( $new,
|
||||||
":content_file" => $CONFIG{'location'}
|
":content_file" => $CONFIG{'location'} . "/$session.tar"
|
||||||
. "/$session.tar" );
|
);
|
||||||
|
|
||||||
#
|
#
|
||||||
# If it worked .. then untar, remove, and return.
|
# If it worked .. then untar, remove, and return.
|
||||||
#
|
#
|
||||||
system(
|
system( "cd $CONFIG{'location'} && tar --numeric-owner -xf $session.tar && rm -f $CONFIG{'location'}/$session.tar" );
|
||||||
"cd $CONFIG{'location'} && tar --numeric-owner -xf $session.tar && rm -f $CONFIG{'location'}/$session.tar"
|
|
||||||
);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep($sleep);
|
sleep( $sleep );
|
||||||
$attempt += 1;
|
$attempt += 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
print("ERROR: Timeout waiting for image to be ready.");
|
print ( "ERROR: Timeout waiting for image to be ready." );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print(
|
print( "ERROR: Failed to find session. Received this:\n$content\n" );
|
||||||
"ERROR: Failed to find session. Received this:\n$content\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print( "ERROR: Submitting the image create request failed:\n"
|
print( "ERROR: Submitting the image create request failed:\n" . $response->status_line );
|
||||||
. $response->status_line );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Install a new distribution of GNU/Linux using the rpmstrap tool.
|
Install a new distribution of GNU/Linux using the rpmstrap tool.
|
||||||
@@ -931,19 +931,17 @@ sub do_image_server
|
|||||||
|
|
||||||
sub do_rinse
|
sub do_rinse
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# The command we're going to run.
|
# The command we're going to run.
|
||||||
#
|
#
|
||||||
my $command =
|
my $command = "rinse --distribution=$CONFIG{'dist'} --directory=$CONFIG{'location'}";
|
||||||
"rinse --distribution=$CONFIG{'dist'} --directory=$CONFIG{'location'}";
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Propogate the --arch argument
|
# Propogate the --arch argument
|
||||||
#
|
#
|
||||||
if ( $CONFIG{'arch'} )
|
if ( $CONFIG{'arch'} )
|
||||||
{
|
{
|
||||||
$command .= " --arch $CONFIG{'arch'}";
|
$command .= " --arch $CONFIG{'arch'}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -955,7 +953,7 @@ sub do_rinse
|
|||||||
$command .= " --verbose";
|
$command .= " --verbose";
|
||||||
}
|
}
|
||||||
|
|
||||||
runCommand($command);
|
runCommand( $command );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -974,7 +972,7 @@ sub do_rpmstrap
|
|||||||
#
|
#
|
||||||
# Propogate the verbosity setting.
|
# Propogate the verbosity setting.
|
||||||
#
|
#
|
||||||
my $EXTRA = '';
|
my $EXTRA='';
|
||||||
if ( $CONFIG{'verbose'} )
|
if ( $CONFIG{'verbose'} )
|
||||||
{
|
{
|
||||||
$EXTRA .= " --verbose";
|
$EXTRA .= " --verbose";
|
||||||
@@ -992,17 +990,18 @@ sub do_rpmstrap
|
|||||||
# Setup mirror if present.
|
# Setup mirror if present.
|
||||||
#
|
#
|
||||||
my $mirror = "";
|
my $mirror = "";
|
||||||
$mirror = $CONFIG{'mirror'} if ( $CONFIG{'mirror'} );
|
$mirror = $CONFIG{'mirror'} if ( $CONFIG{'mirror'} );
|
||||||
|
|
||||||
#
|
#
|
||||||
# The command we're going to run.
|
# The command we're going to run.
|
||||||
#
|
#
|
||||||
my $command = "rpmstrap $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $mirror";
|
my $command = "rpmstrap $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $mirror";
|
||||||
runCommand($command);
|
runCommand( $command );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=begin doc
|
=begin doc
|
||||||
|
|
||||||
Install a new image of a distribution using `tar`.
|
Install a new image of a distribution using `tar`.
|
||||||
@@ -1013,15 +1012,14 @@ sub do_rpmstrap
|
|||||||
|
|
||||||
sub do_tar
|
sub do_tar
|
||||||
{
|
{
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find the tar command to run from the configuration file.
|
# Find the tar command to run from the configuration file.
|
||||||
#
|
#
|
||||||
my $cmd = $CONFIG{'tar-cmd'};
|
my $cmd = $CONFIG{'tar-cmd'} ;
|
||||||
if ( !defined($cmd) )
|
if ( !defined( $cmd ) )
|
||||||
{
|
{
|
||||||
print "Falling back to default tar command\n";
|
print "Falling back to default tar command\n";
|
||||||
$cmd = '/bin/tar --numeric-owner -xvf $src'; # Note: single quotes.
|
$cmd = '/bin/tar --numeric-owner -xvf $src'; # Note: single quotes.
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1032,5 +1030,5 @@ sub do_tar
|
|||||||
#
|
#
|
||||||
# Run a command to copy an installed system into the new root.
|
# Run a command to copy an installed system into the new root.
|
||||||
#
|
#
|
||||||
runCommand("cd $CONFIG{'location'} && $cmd");
|
runCommand( "cd $CONFIG{'location'} && $cmd" );
|
||||||
}
|
}
|
||||||
|
|||||||
91
debian/changelog
vendored
91
debian/changelog
vendored
@@ -1,62 +1,3 @@
|
|||||||
xen-tools (4.1-1) unstable; urgency=low
|
|
||||||
|
|
||||||
- New command line argument '--no-hosts' to avoid touching /etc/hosts
|
|
||||||
on dom0
|
|
||||||
- New command line argument '--pygrub' to setup a guest for pygrub use.
|
|
||||||
- Generated configuration file should work for --image-dev + --swap-dev
|
|
||||||
again.
|
|
||||||
- Always use /dev/pts for new images.
|
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Sun, 23 Nov 2008 13:06:01 +0000
|
|
||||||
|
|
||||||
xen-tools (3.9-6) unstable; urgency=low
|
|
||||||
|
|
||||||
- Allow command line flags to be unset.
|
|
||||||
Thanks to Ruud Koolen for the patch.
|
|
||||||
(Closes: #484338)
|
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Tue, 14 Oct 2008 22:00:22 +0000
|
|
||||||
|
|
||||||
xen-tools (3.9-5) unstable; urgency=medium
|
|
||||||
|
|
||||||
- Record the ARCH for RPM-based distros.
|
|
||||||
(Closes: #475125)
|
|
||||||
- Abort if the generated configuration file already exists.
|
|
||||||
(Closes: #499475)
|
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Mon, 13 Oct 2008 19:20:21 +0000
|
|
||||||
|
|
||||||
xen-tools (3.9-4) unstable; urgency=high
|
|
||||||
|
|
||||||
* Changed two defaults in xen-tools.conf to conform
|
|
||||||
to the defaults used by the xen packages:
|
|
||||||
+ serial_device: tty1 -> hvc0
|
|
||||||
+ disk_device: sda -> xvda
|
|
||||||
|
|
||||||
* Priority High because of RC bug. (closes: #499282)
|
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Tue, 30 Sep 2008 02:02:21 +0300
|
|
||||||
|
|
||||||
xen-tools (3.9-3) unstable; urgency=medium
|
|
||||||
|
|
||||||
- Ensure that Fedora guests get /dev/pts mounted.
|
|
||||||
Thanks to Giovanni Biscuolo (Closes: #474919)
|
|
||||||
- Add the new hostnames to /etc/hosts on the dom0 in the correct order.
|
|
||||||
Thanks to Wolfgang Karall (Closes: #477775)
|
|
||||||
- Ensure that packages are remoed non-interactively for scripted stuff.
|
|
||||||
Thanks to Wolfgang Karall (Closes: #477629)
|
|
||||||
- Correctly handle custom partitioning systems.
|
|
||||||
Thanks to Stéphane AICARDI (Closes: #477334)
|
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Wed, 20 Feb 2007 21:22:23 +0000
|
|
||||||
|
|
||||||
xen-tools (3.9-2) unstable; urgency=high
|
|
||||||
|
|
||||||
- Ensure that the hook scripts which setup networking details for
|
|
||||||
Debian & Ubuntu guests will correctly setup teh broadcast address.
|
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Wed, 20 Feb 2007 21:22:23 +0000
|
|
||||||
|
|
||||||
xen-tools (3.9-1) unstable; urgency=low
|
xen-tools (3.9-1) unstable; urgency=low
|
||||||
|
|
||||||
- general:
|
- general:
|
||||||
@@ -96,9 +37,9 @@ xen-tools (3.8-1) unstable; urgency=low
|
|||||||
(Closes: #439233)
|
(Closes: #439233)
|
||||||
* Use 'apt-get remove' rather than 'dpkg --purge' when removing packages
|
* Use 'apt-get remove' rather than 'dpkg --purge' when removing packages
|
||||||
in hooks. (Closes: #441981)
|
in hooks. (Closes: #441981)
|
||||||
|
|
||||||
[ Radu Spineanu ]
|
[ Radu Spineanu ]
|
||||||
* debian/control: Roland Stigge and I switched maintainer places.
|
* debian/control: Roland Stigge and I switched maintainer places.
|
||||||
* debian/control: Added Steve Kemp to Uploaders.
|
* debian/control: Added Steve Kemp to Uploaders.
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Wed, 03 Oct 2007 00:39:58 +0300
|
-- Radu Spineanu <radu@debian.org> Wed, 03 Oct 2007 00:39:58 +0300
|
||||||
@@ -208,8 +149,8 @@ xen-tools (3.0-1) unstable; urgency=low
|
|||||||
|
|
||||||
xen-tools (3.0~beta1-2) unstable; urgency=low
|
xen-tools (3.0~beta1-2) unstable; urgency=low
|
||||||
|
|
||||||
* Remove old symlinks and directories during preinst. (closes: #401834)
|
* Remove old symlinks and directories during preinst. (closes: #401834)
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Wed, 6 Dec 2006 15:58:44 +0200
|
-- Radu Spineanu <radu@debian.org> Wed, 6 Dec 2006 15:58:44 +0200
|
||||||
|
|
||||||
xen-tools (3.0~beta1-1) unstable; urgency=low
|
xen-tools (3.0~beta1-1) unstable; urgency=low
|
||||||
@@ -217,7 +158,7 @@ xen-tools (3.0~beta1-1) unstable; urgency=low
|
|||||||
* Development snapshot
|
* Development snapshot
|
||||||
* Mention the --mac option in the man page.
|
* Mention the --mac option in the man page.
|
||||||
(closes: #399708)
|
(closes: #399708)
|
||||||
* Set the locale version to 'C' to avoid perl warnings.
|
* Set the locale version to 'C' to avoid perl warnings.
|
||||||
(closes: #399778)
|
(closes: #399778)
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Mon, 4 Dec 2006 16:55:31 +0200
|
-- Radu Spineanu <radu@debian.org> Mon, 4 Dec 2006 16:55:31 +0200
|
||||||
@@ -240,7 +181,7 @@ xen-tools (2.8-2) unstable; urgency=low
|
|||||||
|
|
||||||
xen-tools (2.8-1) unstable; urgency=low
|
xen-tools (2.8-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream release
|
* New upstream release
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Wed, 8 Nov 2006 00:35:40 +0200
|
-- Radu Spineanu <radu@debian.org> Wed, 8 Nov 2006 00:35:40 +0200
|
||||||
|
|
||||||
@@ -262,13 +203,13 @@ xen-tools (2.7-3) unstable; urgency=low
|
|||||||
|
|
||||||
xen-tools (2.7-2) unstable; urgency=low
|
xen-tools (2.7-2) unstable; urgency=low
|
||||||
|
|
||||||
* Fixed 2.6-2 changelog entry.
|
* Fixed 2.6-2 changelog entry.
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Sat, 14 Oct 2006 02:21:25 +0300
|
-- Radu Spineanu <radu@debian.org> Sat, 14 Oct 2006 02:21:25 +0300
|
||||||
|
|
||||||
xen-tools (2.7-1) unstable; urgency=low
|
xen-tools (2.7-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream release
|
* New upstream release
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Sat, 14 Oct 2006 02:16:20 +0300
|
-- Radu Spineanu <radu@debian.org> Sat, 14 Oct 2006 02:16:20 +0300
|
||||||
|
|
||||||
@@ -329,7 +270,7 @@ xen-tools (2.3-1) unstable; urgency=high
|
|||||||
using a specific version of debootstrap.
|
using a specific version of debootstrap.
|
||||||
- Updated manpages to avoid word-wrapping.
|
- Updated manpages to avoid word-wrapping.
|
||||||
- Updated --noswap option such that a LVM swap volume isn't created.
|
- Updated --noswap option such that a LVM swap volume isn't created.
|
||||||
- Reverted the usage of '--keep-debootstrap-dir' since that is a
|
- Reverted the usage of '--keep-debootstrap-dir' since that is a
|
||||||
"recent" thing. Will switch to keeping a global logfile for error
|
"recent" thing. Will switch to keeping a global logfile for error
|
||||||
purposes.
|
purposes.
|
||||||
(Closes: #383589)
|
(Closes: #383589)
|
||||||
@@ -371,7 +312,7 @@ xen-tools (2.2-2) unstable; urgency=low
|
|||||||
xen-tools (2.2-1) unstable; urgency=high
|
xen-tools (2.2-1) unstable; urgency=high
|
||||||
|
|
||||||
* New upstream release, fixes several important bugs hence urgency=high.
|
* New upstream release, fixes several important bugs hence urgency=high.
|
||||||
- /etc/fstab creation generated correctly for reiserfs
|
- /etc/fstab creation generated correctly for reiserfs
|
||||||
(Closes: #379023) (Closes: #379096)
|
(Closes: #379023) (Closes: #379096)
|
||||||
- --force works with xfs filesystems.
|
- --force works with xfs filesystems.
|
||||||
(Closes: #377684)
|
(Closes: #377684)
|
||||||
@@ -422,7 +363,7 @@ xen-tools (2.0-1) unstable; urgency=low
|
|||||||
(Closes: #373800)
|
(Closes: #373800)
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Tue, 20 Jun 2006 09:57:45 +0000
|
-- Steve Kemp <skx@debian.org> Tue, 20 Jun 2006 09:57:45 +0000
|
||||||
|
|
||||||
xen-tools (1.6-1) unstable; urgency=low
|
xen-tools (1.6-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream release (closes: #368983)
|
* New upstream release (closes: #368983)
|
||||||
@@ -465,26 +406,26 @@ xen-tools (1.4-1) unstable; urgency=low
|
|||||||
(Closes: #363070)
|
(Closes: #363070)
|
||||||
* Added new option --initrd to specify the initial ramdisk.
|
* Added new option --initrd to specify the initial ramdisk.
|
||||||
(Closes: #365500)
|
(Closes: #365500)
|
||||||
|
|
||||||
-- Steve Kemp <skx@debian.org> Sun, 7 May 2006 14:43:43 +0000
|
-- Steve Kemp <skx@debian.org> Sun, 7 May 2006 14:43:43 +0000
|
||||||
|
|
||||||
xen-tools (1.3-1) unstable; urgency=low
|
xen-tools (1.3-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream release
|
* New upstream release
|
||||||
+ Ignore .dpkg-(new|old) files in the hooks directory
|
+ Ignore .dpkg-(new|old) files in the hooks directory
|
||||||
(closes: #357716)
|
(closes: #357716)
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Sat, 15 Apr 2006 13:44:36 +0300
|
-- Radu Spineanu <radu@debian.org> Sat, 15 Apr 2006 13:44:36 +0300
|
||||||
|
|
||||||
xen-tools (1.1-1) unstable; urgency=low
|
xen-tools (1.1-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream release
|
* New upstream release
|
||||||
+ Disk devices are no longer created one unit bigger than asked
|
+ Disk devices are no longer created one unit bigger than asked
|
||||||
(closes: #353155)
|
(closes: #353155)
|
||||||
+ Populate /dev on the virtual server (closes: #352942)
|
+ Populate /dev on the virtual server (closes: #352942)
|
||||||
+ Added --use-ide flag in case people want ide style device names
|
+ Added --use-ide flag in case people want ide style device names
|
||||||
(closes: #352937)
|
(closes: #352937)
|
||||||
+ xen.cfg is no longer broken when using LVM
|
+ xen.cfg is no longer broken when using LVM
|
||||||
|
|
||||||
-- Radu Spineanu <radu@debian.org> Tue, 21 Feb 2006 01:28:28 +0200
|
-- Radu Spineanu <radu@debian.org> Tue, 21 Feb 2006 01:28:28 +0200
|
||||||
|
|
||||||
|
|||||||
2
debian/control
vendored
2
debian/control
vendored
@@ -4,7 +4,7 @@ Priority: extra
|
|||||||
Maintainer: Roland Stigge <stigge@antcom.de>
|
Maintainer: Roland Stigge <stigge@antcom.de>
|
||||||
Uploaders: Radu Spineanu <radu@debian.org>, Steve Kemp <skx@debian.org>
|
Uploaders: Radu Spineanu <radu@debian.org>, Steve Kemp <skx@debian.org>
|
||||||
Build-Depends: debhelper (>= 4.0.0), libtest-pod-perl, libtext-template-perl
|
Build-Depends: debhelper (>= 4.0.0), libtest-pod-perl, libtext-template-perl
|
||||||
Standards-Version: 3.8.0
|
Standards-Version: 3.7.3
|
||||||
Homepage: http://xen-tools.org/software/xen-tools
|
Homepage: http://xen-tools.org/software/xen-tools
|
||||||
|
|
||||||
Package: xen-tools
|
Package: xen-tools
|
||||||
|
|||||||
0
debian/examples/setup-kernel-initrd
vendored
Executable file → Normal file
0
debian/examples/setup-kernel-initrd
vendored
Executable file → Normal file
0
debian/examples/update-modules
vendored
Executable file → Normal file
0
debian/examples/update-modules
vendored
Executable file → Normal file
0
debian/preinst
vendored
Executable file → Normal file
0
debian/preinst
vendored
Executable file → Normal file
@@ -248,17 +248,17 @@ reiser_options = defaults
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If you're using the lenny or later version of the Xen guest kernel you will
|
# If you're using a newer version of the Xen guest kernel you will
|
||||||
# need to make sure that you use 'hvc0' for the guest serial device,
|
# need to make sure that you use 'xvc0' for the guest serial device,
|
||||||
# and 'xvdX' instead of 'sdX' for serial devices.
|
# and 'xvdX' instead of 'sdX' for serial devices.
|
||||||
#
|
#
|
||||||
# You may specify the things to use here:
|
# You may specify the things to use here:
|
||||||
#
|
#
|
||||||
# serial_device = hvc0 #default
|
# serial_device = tty1 #default
|
||||||
# serial_device = tty1
|
# serial_device = xvc0
|
||||||
#
|
#
|
||||||
# disk_device = xvda #default
|
# disk_device = sda #default
|
||||||
# disk_device = sda
|
# disk_device = xvda
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
77
etc/xm.tmpl
77
etc/xm.tmpl
@@ -6,76 +6,37 @@
|
|||||||
#
|
#
|
||||||
# Kernel + memory size
|
# Kernel + memory size
|
||||||
#
|
#
|
||||||
{ if ( ( $kernel ) && ( !defined($pygrub)) )
|
{ if ( $kernel )
|
||||||
{
|
{
|
||||||
$OUT.= "kernel = '$kernel'";
|
$OUT.= "kernel = '$kernel'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ if ( ( $initrd ) && ( !defined($pygrub)) )
|
{ if ( $initrd )
|
||||||
{
|
{
|
||||||
$OUT.= "ramdisk = '$initrd'";
|
$OUT.= "ramdisk = '$initrd'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
|
||||||
if ( $pygrub )
|
|
||||||
{
|
|
||||||
$OUT .= "bootloader = '/usr/bin/pygrub'\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memory = '{$memory}'
|
memory = '{$memory}'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Disk device(s).
|
# Disk device(s).
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
if ( !defined($image_vbd ) )
|
for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
|
||||||
{
|
{
|
||||||
for ( my $i = $#PARTITIONS; $i >= 0 ; $i-- )
|
|
||||||
{
|
|
||||||
if ( $PARTITIONS[$i]{'mountpoint'} eq '/' )
|
if ( $PARTITIONS[$i]{'mountpoint'} eq '/' )
|
||||||
{
|
{
|
||||||
$OUT .= "root = '/dev/$device" . ($i + 1) . " ro'\n";
|
$OUT .= "root = '/dev/$device" . ($i + 1) . " ro'\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$OUT .= "disk = [\n";
|
|
||||||
for ( my $i = $#PARTITIONS; $i >= 0 ; $i-- )
|
|
||||||
{
|
|
||||||
$OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
|
|
||||||
}
|
|
||||||
$OUT .= " ]\n";
|
|
||||||
}
|
}
|
||||||
|
$OUT .= "disk = [\n";
|
||||||
|
for ( my $i = 0; $i <= $#PARTITIONS; $i++ )
|
||||||
|
{
|
||||||
|
$OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
|
||||||
|
}
|
||||||
|
$OUT .= " ]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Physical volumes
|
|
||||||
#
|
|
||||||
{
|
|
||||||
if ( ( $swap_vbd ) && ( $image_vbd ) )
|
|
||||||
{
|
|
||||||
$OUT .= "root = '/dev/$device" . "2 ro'\n";
|
|
||||||
|
|
||||||
$OUT .= "disk = [ ";
|
|
||||||
|
|
||||||
if ( $image_vbd )
|
|
||||||
{
|
|
||||||
$OUT .= "'$image_vbd," . $device . "2,w'";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $swap_vbd )
|
|
||||||
{
|
|
||||||
if ( $image_vbd )
|
|
||||||
{
|
|
||||||
$OUT .= ",";
|
|
||||||
}
|
|
||||||
|
|
||||||
$OUT .= "'$swap_vbd," . $device . "1,w'";
|
|
||||||
}
|
|
||||||
$OUT .= " ]\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Hostname
|
# Hostname
|
||||||
#
|
#
|
||||||
@@ -91,12 +52,12 @@ name = '{$hostname}'
|
|||||||
# Setup the mac address, if present.
|
# Setup the mac address, if present.
|
||||||
my $m = '';
|
my $m = '';
|
||||||
if ( $mac )
|
if ( $mac )
|
||||||
{
|
{
|
||||||
$m = "mac=$mac"
|
$m = "mac=$mac"
|
||||||
}
|
}
|
||||||
|
|
||||||
$OUT .= "vif = [ '$m' ]";
|
$OUT .= "vif = [ '$m' ]";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#
|
#
|
||||||
@@ -104,20 +65,12 @@ name = '{$hostname}'
|
|||||||
#
|
#
|
||||||
my $m = '';
|
my $m = '';
|
||||||
if ( $mac )
|
if ( $mac )
|
||||||
{
|
{
|
||||||
$m = ",mac=$mac"
|
$m = ",mac=$mac"
|
||||||
}
|
}
|
||||||
|
|
||||||
my $vn = '';
|
$OUT .= "vif = [ 'ip=$ip1";
|
||||||
if ( $vifname )
|
$OUT .= "$m' ]";
|
||||||
{
|
|
||||||
$vn = ",vifname=$vifname";
|
|
||||||
}
|
|
||||||
|
|
||||||
$OUT .= "vif = [ 'ip=$ip1";
|
|
||||||
$OUT .= "$m";
|
|
||||||
$OUT .= "$vn";
|
|
||||||
$OUT .= "' ]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
prefix=$1
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Source our common functions
|
|
||||||
#
|
|
||||||
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
|
||||||
. /usr/lib/xen-tools/common.sh
|
|
||||||
else
|
|
||||||
. ./hooks/common.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our start
|
|
||||||
#
|
|
||||||
logMessage Script $0 starting
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Record arch, if present.
|
|
||||||
#
|
|
||||||
if [ -d $prefix/etc/rpm ]; then
|
|
||||||
|
|
||||||
logMessage Found /etc/rpm
|
|
||||||
|
|
||||||
#
|
|
||||||
# If i386 then record this
|
|
||||||
#
|
|
||||||
if [ "$arch" = "i386" ]; then
|
|
||||||
echo "i386-fedora-linux-gnu" >> $prefix/etc/rpm/platform
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
|
|
||||||
logMessage Failed to find /etc/rpm
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our finish
|
|
||||||
#
|
|
||||||
logMessage Script $0 finished
|
|
||||||
|
|
||||||
@@ -89,27 +89,23 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
|
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
|
# and there is an installation of dnsmasq installed then
|
||||||
|
# reload it.
|
||||||
|
#
|
||||||
|
# This will let the local LAN clients lookup the new address.
|
||||||
|
#
|
||||||
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
#
|
logMessage Allowing DNSMasq to restart.
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
# and there is an installation of dnsmasq installed then
|
|
||||||
# reload it.
|
|
||||||
#
|
|
||||||
# This will let the local LAN clients lookup the new address.
|
|
||||||
#
|
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ cat <<E_O_FSTAB > ${prefix}/etc/fstab
|
|||||||
#
|
#
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
|
|
||||||
E_O_FSTAB
|
E_O_FSTAB
|
||||||
for part in `seq 1 ${NUMPARTITIONS}`; do
|
for part in `seq 1 ${NUMPARTITIONS}`; do
|
||||||
eval "PARTITION=\"\${PARTITION${part}}\""
|
eval "PARTITION=\"\${PARTITION${part}}\""
|
||||||
@@ -76,7 +75,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
x=$(( $x+1 ))
|
x=$(( $x+1 ))
|
||||||
done
|
done
|
||||||
IFS="${OLDIFS}"
|
IFS="${OLDIFS}"
|
||||||
|
|
||||||
case "${partdata2}" in
|
case "${partdata2}" in
|
||||||
xfs)
|
xfs)
|
||||||
has_xfs=1
|
has_xfs=1
|
||||||
@@ -85,7 +84,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
has_reiserfs=1
|
has_reiserfs=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "${partdata2}" = "swap" ]; then
|
if [ "${partdata2}" = "swap" ]; then
|
||||||
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
prefix=$1
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Source our common functions
|
|
||||||
#
|
|
||||||
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
|
||||||
. /usr/lib/xen-tools/common.sh
|
|
||||||
else
|
|
||||||
. ./hooks/common.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our start
|
|
||||||
#
|
|
||||||
logMessage Script $0 starting
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Record arch, if present.
|
|
||||||
#
|
|
||||||
if [ -d $prefix/etc/rpm ]; then
|
|
||||||
|
|
||||||
logMessage Found /etc/rpm
|
|
||||||
|
|
||||||
#
|
|
||||||
# If i386 then record this
|
|
||||||
#
|
|
||||||
if [ "$arch" = "i386" ]; then
|
|
||||||
echo "i386-fedora-linux-gnu" >> $prefix/etc/rpm/platform
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
|
|
||||||
logMessage Failed to find /etc/rpm
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our finish
|
|
||||||
#
|
|
||||||
logMessage Script $0 finished
|
|
||||||
|
|
||||||
@@ -89,24 +89,23 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
#
|
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
|
||||||
# and there is an installation of dnsmasq installed then
|
|
||||||
# reload it.
|
|
||||||
#
|
|
||||||
# This will let the local LAN clients lookup the new address.
|
|
||||||
#
|
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
#
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
fi
|
# and there is an installation of dnsmasq installed then
|
||||||
|
# reload it.
|
||||||
|
#
|
||||||
|
# This will let the local LAN clients lookup the new address.
|
||||||
|
#
|
||||||
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
|
logMessage Allowing DNSMasq to restart.
|
||||||
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# might develop.
|
# might develop.
|
||||||
#
|
#
|
||||||
# Steve
|
# Steve
|
||||||
# --
|
# --
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ disableStartStopDaemon ()
|
|||||||
chmod 755 "${daemonfile}"
|
chmod 755 "${daemonfile}"
|
||||||
logMessage "start-stop-daemon disabled / made a stub."
|
logMessage "start-stop-daemon disabled / made a stub."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -151,7 +151,7 @@ enableStartStopDaemon ()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -182,7 +182,7 @@ removeDebianPackage ()
|
|||||||
#
|
#
|
||||||
# Purge the packages we've been given.
|
# Purge the packages we've been given.
|
||||||
#
|
#
|
||||||
chroot ${prefix} /usr/bin/apt-get remove --yes --purge "$@"
|
chroot ${prefix} /usr/bin/apt-get remove --purge "$@"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ installGentooPackage ()
|
|||||||
# Log our options
|
# Log our options
|
||||||
#
|
#
|
||||||
logMessage "Installing Gentoo package ${package} to prefix ${prefix}"
|
logMessage "Installing Gentoo package ${package} to prefix ${prefix}"
|
||||||
|
|
||||||
logMessage "NOTE: Not doing anything - this is a stub - FIXME"
|
logMessage "NOTE: Not doing anything - this is a stub - FIXME"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,25 +89,24 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
# and there is an installation of dnsmasq installed then
|
# and there is an installation of dnsmasq installed then
|
||||||
# reload it.
|
# reload it.
|
||||||
#
|
#
|
||||||
# This will let the local LAN clients lookup the new address.
|
# This will let the local LAN clients lookup the new address.
|
||||||
#
|
#
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
logMessage Allowing DNSMasq to restart.
|
||||||
|
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ cat <<E_O_FSTAB > ${prefix}/etc/fstab
|
|||||||
#
|
#
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
|
|
||||||
E_O_FSTAB
|
E_O_FSTAB
|
||||||
for part in `seq 1 ${NUMPARTITIONS}`; do
|
for part in `seq 1 ${NUMPARTITIONS}`; do
|
||||||
eval "PARTITION=\"\${PARTITION${part}}\""
|
eval "PARTITION=\"\${PARTITION${part}}\""
|
||||||
@@ -73,7 +72,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
x=$(( $x+1 ))
|
x=$(( $x+1 ))
|
||||||
done
|
done
|
||||||
IFS="${OLDIFS}"
|
IFS="${OLDIFS}"
|
||||||
|
|
||||||
case "${partdata2}" in
|
case "${partdata2}" in
|
||||||
xfs)
|
xfs)
|
||||||
has_xfs=1
|
has_xfs=1
|
||||||
@@ -82,7 +81,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
has_reiserfs=1
|
has_reiserfs=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "${partdata2}" = "swap" ]; then
|
if [ "${partdata2}" = "swap" ]; then
|
||||||
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ setupStaticNetworking ()
|
|||||||
#
|
#
|
||||||
bcast='';
|
bcast='';
|
||||||
if [ ! -z "${broadcast}" ]; then
|
if [ ! -z "${broadcast}" ]; then
|
||||||
bcast=" broadcast ${broadcast}"
|
bcast=' broadcast ${broadcast}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -89,24 +89,23 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
# and there is an installation of dnsmasq installed then
|
# and there is an installation of dnsmasq installed then
|
||||||
# reload it.
|
# reload it.
|
||||||
#
|
#
|
||||||
# This will let the local LAN clients lookup the new address.
|
# This will let the local LAN clients lookup the new address.
|
||||||
#
|
#
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
logMessage Allowing DNSMasq to restart.
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
|
||||||
fi
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ cat <<E_O_FSTAB > ${prefix}/etc/fstab
|
|||||||
#
|
#
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
|
|
||||||
E_O_FSTAB
|
E_O_FSTAB
|
||||||
for part in `seq 1 ${NUMPARTITIONS}`; do
|
for part in `seq 1 ${NUMPARTITIONS}`; do
|
||||||
eval "PARTITION=\"\${PARTITION${part}}\""
|
eval "PARTITION=\"\${PARTITION${part}}\""
|
||||||
@@ -72,7 +71,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
x=$(( $x+1 ))
|
x=$(( $x+1 ))
|
||||||
done
|
done
|
||||||
IFS="${OLDIFS}"
|
IFS="${OLDIFS}"
|
||||||
|
|
||||||
case "${partdata2}" in
|
case "${partdata2}" in
|
||||||
xfs)
|
xfs)
|
||||||
has_xfs=1
|
has_xfs=1
|
||||||
@@ -81,7 +80,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
has_reiserfs=1
|
has_reiserfs=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "${partdata2}" = "swap" ]; then
|
if [ "${partdata2}" = "swap" ]; then
|
||||||
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ cp /etc/resolv.conf ${prefix}/etc
|
|||||||
#
|
#
|
||||||
# Process any of the present apt-conf setup lines.
|
# Process any of the present apt-conf setup lines.
|
||||||
#
|
#
|
||||||
for i in /etc/apt/apt.conf $(run-parts --list /etc/apt/apt.conf.d) ; do
|
for i in /etc/apt/apt.conf /etc/apt/apt.conf.d/* ; do
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If the file exists. (Need this in case the literal glob fails.)
|
# If the file exists. (Need this in case the literal glob fails.)
|
||||||
@@ -53,8 +52,7 @@ for i in /etc/apt/apt.conf $(run-parts --list /etc/apt/apt.conf.d) ; do
|
|||||||
# Save the matching line(s) to the proxy guess file.
|
# Save the matching line(s) to the proxy guess file.
|
||||||
#
|
#
|
||||||
logMessage The use of a proxy detected.
|
logMessage The use of a proxy detected.
|
||||||
|
grep -i HTTP::Proxy $i >> ${prefix}/etc/apt/apt.conf.d/proxy-guess
|
||||||
grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -42,10 +42,7 @@ if [ ! -z "${serial_device}" ]; then
|
|||||||
|
|
||||||
# replace existing device.
|
# replace existing device.
|
||||||
mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/${serial_device}
|
mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/${serial_device}
|
||||||
sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/event.d/${serial_device}
|
sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/inittab
|
||||||
[ -f ${prefix}/etc/inittab ] && sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/inittab
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# make sure that it is allowed to login.
|
# make sure that it is allowed to login.
|
||||||
echo $serial_device >> ${prefix}/etc/securetty
|
echo $serial_device >> ${prefix}/etc/securetty
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ setupStaticNetworking ()
|
|||||||
#
|
#
|
||||||
bcast='';
|
bcast='';
|
||||||
if [ ! -z "${broadcast}" ]; then
|
if [ ! -z "${broadcast}" ]; then
|
||||||
bcast=" broadcast ${broadcast}"
|
bcast=' broadcast ${broadcast}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -88,24 +88,23 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
# and there is an installation of dnsmasq installed then
|
# and there is an installation of dnsmasq installed then
|
||||||
# reload it.
|
# reload it.
|
||||||
#
|
#
|
||||||
# This will let the local LAN clients lookup the new address.
|
# This will let the local LAN clients lookup the new address.
|
||||||
#
|
#
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
logMessage Allowing DNSMasq to restart.
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
|
||||||
fi
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ cat <<E_O_FSTAB > ${prefix}/etc/fstab
|
|||||||
#
|
#
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
|
|
||||||
E_O_FSTAB
|
E_O_FSTAB
|
||||||
for part in `seq 1 ${NUMPARTITIONS}`; do
|
for part in `seq 1 ${NUMPARTITIONS}`; do
|
||||||
eval "PARTITION=\"\${PARTITION${part}}\""
|
eval "PARTITION=\"\${PARTITION${part}}\""
|
||||||
@@ -73,7 +72,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
x=$(( $x+1 ))
|
x=$(( $x+1 ))
|
||||||
done
|
done
|
||||||
IFS="${OLDIFS}"
|
IFS="${OLDIFS}"
|
||||||
|
|
||||||
case "${partdata2}" in
|
case "${partdata2}" in
|
||||||
xfs)
|
xfs)
|
||||||
has_xfs=1
|
has_xfs=1
|
||||||
@@ -82,7 +81,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
has_reiserfs=1
|
has_reiserfs=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "${partdata2}" = "swap" ]; then
|
if [ "${partdata2}" = "swap" ]; then
|
||||||
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
prefix=$1
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Source our common functions
|
|
||||||
#
|
|
||||||
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
|
||||||
. /usr/lib/xen-tools/common.sh
|
|
||||||
else
|
|
||||||
. ./hooks/common.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our start
|
|
||||||
#
|
|
||||||
logMessage Script $0 starting
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Record arch, if present.
|
|
||||||
#
|
|
||||||
if [ -d $prefix/etc/rpm ]; then
|
|
||||||
|
|
||||||
logMessage Found /etc/rpm
|
|
||||||
|
|
||||||
#
|
|
||||||
# If i386 then record this
|
|
||||||
#
|
|
||||||
if [ "$arch" = "i386" ]; then
|
|
||||||
echo "i386-fedora-linux-gnu" >> $prefix/etc/rpm/platform
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
|
|
||||||
logMessage Failed to find /etc/rpm
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our finish
|
|
||||||
#
|
|
||||||
logMessage Script $0 finished
|
|
||||||
|
|
||||||
@@ -89,25 +89,23 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
# and there is an installation of dnsmasq installed then
|
# and there is an installation of dnsmasq installed then
|
||||||
# reload it.
|
# reload it.
|
||||||
#
|
#
|
||||||
# This will let the local LAN clients lookup the new address.
|
# This will let the local LAN clients lookup the new address.
|
||||||
#
|
#
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
logMessage Allowing DNSMasq to restart.
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ cat <<E_O_FSTAB > ${prefix}/etc/fstab
|
|||||||
#
|
#
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
|
|
||||||
E_O_FSTAB
|
E_O_FSTAB
|
||||||
for part in `seq 1 ${NUMPARTITIONS}`; do
|
for part in `seq 1 ${NUMPARTITIONS}`; do
|
||||||
eval "PARTITION=\"\${PARTITION${part}}\""
|
eval "PARTITION=\"\${PARTITION${part}}\""
|
||||||
@@ -76,7 +75,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
x=$(( $x+1 ))
|
x=$(( $x+1 ))
|
||||||
done
|
done
|
||||||
IFS="${OLDIFS}"
|
IFS="${OLDIFS}"
|
||||||
|
|
||||||
case "${partdata2}" in
|
case "${partdata2}" in
|
||||||
xfs)
|
xfs)
|
||||||
has_xfs=1
|
has_xfs=1
|
||||||
@@ -85,7 +84,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
has_reiserfs=1
|
has_reiserfs=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "${partdata2}" = "swap" ]; then
|
if [ "${partdata2}" = "swap" ]; then
|
||||||
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -96,24 +96,23 @@ if [ -z "${dhcp}" ]; then
|
|||||||
#
|
#
|
||||||
name=`echo ${hostname} | awk -F. '{print $1}'`
|
name=`echo ${hostname} | awk -F. '{print $1}'`
|
||||||
|
|
||||||
if [ -z "${nohosts}" ]; then
|
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
||||||
|
|
||||||
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
|
echo "${ip1} ${name} ${hostname}" >> /etc/hosts
|
||||||
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we've updated the /etc/hosts file on the host machine
|
# If we've updated the /etc/hosts file on the host machine
|
||||||
# and there is an installation of dnsmasq installed then
|
# and there is an installation of dnsmasq installed then
|
||||||
# reload it.
|
# reload it.
|
||||||
#
|
#
|
||||||
# This will let the local LAN clients lookup the new address.
|
# This will let the local LAN clients lookup the new address.
|
||||||
#
|
#
|
||||||
if [ -x /usr/sbin/dnsmasq ] ; then
|
if [ -x /usr/sbin/dnsmasq ] ; then
|
||||||
if [ -e /var/run/dnsmasq.pid ]; then
|
if [ -e /var/run/dnsmasq.pid ]; then
|
||||||
|
|
||||||
logMessage Allowing DNSMasq to restart.
|
logMessage Allowing DNSMasq to restart.
|
||||||
kill -HUP `cat /var/run/dnsmasq.pid`
|
|
||||||
fi
|
kill -HUP `cat /var/run/dnsmasq.pid`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ cat <<E_O_FSTAB > ${prefix}/etc/fstab
|
|||||||
#
|
#
|
||||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||||
proc /proc proc defaults 0 0
|
proc /proc proc defaults 0 0
|
||||||
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
|
|
||||||
E_O_FSTAB
|
E_O_FSTAB
|
||||||
for part in `seq 1 ${NUMPARTITIONS}`; do
|
for part in `seq 1 ${NUMPARTITIONS}`; do
|
||||||
eval "PARTITION=\"\${PARTITION${part}}\""
|
eval "PARTITION=\"\${PARTITION${part}}\""
|
||||||
@@ -73,7 +72,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
x=$(( $x+1 ))
|
x=$(( $x+1 ))
|
||||||
done
|
done
|
||||||
IFS="${OLDIFS}"
|
IFS="${OLDIFS}"
|
||||||
|
|
||||||
case "${partdata2}" in
|
case "${partdata2}" in
|
||||||
xfs)
|
xfs)
|
||||||
has_xfs=1
|
has_xfs=1
|
||||||
@@ -82,7 +81,7 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
|
|||||||
has_reiserfs=1
|
has_reiserfs=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "${partdata2}" = "swap" ]; then
|
if [ "${partdata2}" = "swap" ]; then
|
||||||
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
echo "/dev/${device}${part} none swap sw 0 0" >> ${prefix}/etc/fstab
|
||||||
else
|
else
|
||||||
|
|||||||
41
roles/puppet
41
roles/puppet
@@ -1,41 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# This role installs Puppet upon the new guest system.
|
|
||||||
#
|
|
||||||
# It must make sure that the server is not running before it exits
|
|
||||||
# otherwise the temporary mounted directory will not be unmountable.
|
|
||||||
#
|
|
||||||
|
|
||||||
prefix=$1
|
|
||||||
|
|
||||||
#
|
|
||||||
# Source our common functions - this will let us install a Debian package.
|
|
||||||
#
|
|
||||||
if [ -e /usr/lib/xen-tools/common.sh ]; then
|
|
||||||
. /usr/lib/xen-tools/common.sh
|
|
||||||
else
|
|
||||||
echo "Installation problem"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our start
|
|
||||||
#
|
|
||||||
logMessage Script $0 starting
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Install ssh
|
|
||||||
#
|
|
||||||
installDebianPackage ${prefix} puppet
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Make sure sshd isn't running, this will cause our unmounting of the
|
|
||||||
# disk image to fail..
|
|
||||||
#
|
|
||||||
chroot ${prefix} /etc/init.d/puppet stop
|
|
||||||
|
|
||||||
#
|
|
||||||
# Log our finish
|
|
||||||
#
|
|
||||||
logMessage Script $0 finished
|
|
||||||
@@ -25,7 +25,7 @@ use Test::More qw( no_plan );
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
for i in `rgrep '^use ' .. | grep -v Expect | grep -v POSIX | grep -v Xen:: | grep -v Moose | awk '{print $2}' | tr -d
|
for i in `rgrep '^use ' .. | grep -v Expect | grep -v Xen:: | grep -v Moose | awk '{print $2}' | tr -d
|
||||||
\;\(\) | sort | uniq`; \
|
\;\(\) | sort | uniq`; \
|
||||||
do \
|
do \
|
||||||
echo "BEGIN{ use_ok( '$i' ); }"; \
|
echo "BEGIN{ use_ok( '$i' ); }"; \
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ BEGIN{ use_ok( 'Pod::Usage' ); }
|
|||||||
require_ok( 'Pod::Usage' );
|
require_ok( 'Pod::Usage' );
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN{ use_ok( 'POSIX' ); }
|
||||||
|
require_ok( 'POSIX' );
|
||||||
|
|
||||||
|
|
||||||
BEGIN{ use_ok( 'strict' ); }
|
BEGIN{ use_ok( 'strict' ); }
|
||||||
require_ok( 'strict' );
|
require_ok( 'strict' );
|
||||||
|
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
#
|
|
||||||
# Test that every bash script using variables uses " not '.
|
|
||||||
#
|
|
||||||
# Steve
|
|
||||||
# --
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use File::Find;
|
|
||||||
use Test::More qw( no_plan );
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Find all the files beneath the current directory,
|
|
||||||
# and call 'checkFile' with the name.
|
|
||||||
#
|
|
||||||
my $dir = undef;
|
|
||||||
$dir = "../hooks" if ( -d "../hooks" );
|
|
||||||
$dir = "./hooks" if ( -d "./hooks" );
|
|
||||||
ok( defined( $dir ), "Found hook directory" );
|
|
||||||
find( { wanted => \&checkFile, no_chdir => 1 }, $dir );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check a file; if it is a shell script.
|
|
||||||
#
|
|
||||||
sub checkFile
|
|
||||||
{
|
|
||||||
# The file.
|
|
||||||
my $file = $File::Find::name;
|
|
||||||
|
|
||||||
# We don't care about directories
|
|
||||||
return if ( ! -f $file );
|
|
||||||
|
|
||||||
# Finally mercurial files are fine.
|
|
||||||
return if ( $file =~ /\.hg\// );
|
|
||||||
|
|
||||||
# See if it is a shell script.
|
|
||||||
my $isShell = 0;
|
|
||||||
|
|
||||||
# Read the file.
|
|
||||||
open( INPUT, "<", $file );
|
|
||||||
foreach my $line ( <INPUT> )
|
|
||||||
{
|
|
||||||
if ( ( $line =~ /\/bin\/sh/ ) ||
|
|
||||||
( $line =~ /\/bin\/bash/ ) )
|
|
||||||
{
|
|
||||||
$isShell = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close( INPUT );
|
|
||||||
|
|
||||||
#
|
|
||||||
# Return if it wasn't a perl file.
|
|
||||||
#
|
|
||||||
return if ( ! $isShell );
|
|
||||||
|
|
||||||
#
|
|
||||||
# Now read the file.
|
|
||||||
#
|
|
||||||
open( FILE, "<", $file ) or die "Failed to open file: $file - $!";
|
|
||||||
ok( *FILE, "Opened file: $file" );
|
|
||||||
foreach my $line (<FILE> )
|
|
||||||
{
|
|
||||||
chomp( $line );
|
|
||||||
|
|
||||||
next if (!length( $line ) );
|
|
||||||
next if ( $line =~ /grep|sed|echo|awk|find|policy-rc.d|chroot|logMessage/ );
|
|
||||||
if ( $line =~ /\$/ )
|
|
||||||
{
|
|
||||||
ok( $line !~ /\'/, "Non-masked line '$line'" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close( FILE );
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user