1
0
mirror of synced 2026-02-25 07:50:01 +00:00

Compare commits

...

32 Commits

Author SHA1 Message Date
Steve Kemp
5ed66652ad Use perltidy with no args 2009-01-11 23:22:03 +00:00
Steve Kemp
7b29ec1bdf Fixed tab vs. space 2009-01-11 23:21:25 +00:00
Steve Kemp
31719505f6 Updated. 2009-01-06 21:01:51 +00:00
Steve Kemp
6338ba62c4 Added. 2009-01-06 20:59:55 +00:00
Steve Kemp
3c4e0160ae Updated. 2008-12-10 21:39:59 +00:00
Steve Kemp
84ee1658d1 Another fixup 2008-12-10 21:35:35 +00:00
Steve Kemp
a28bced5e3 Last juggle. 2008-12-09 14:02:04 +00:00
Steve Kemp
8965988439 Hardy + Intrepid now work 2008-12-08 22:56:55 +00:00
Steve Kemp
1d6771c719 Reverse order. 2008-12-08 22:56:28 +00:00
Steve Kemp
3cb87c09e9 Updated. 2008-12-08 20:35:13 +00:00
Steve Kemp
a95d576a4e 1. Work with partitions.
2.  Allow pygrub
2008-11-24 14:37:34 +00:00
Steve Kemp
9d061fe5a6 Always make /dev/pts available 2008-11-24 14:37:14 +00:00
Steve Kemp
22a4774cfe Updated to work with partitions 2008-11-23 21:12:42 +00:00
Steve Kemp
1b6d3dbdeb Delete the file if it exists 2008-11-23 21:12:36 +00:00
Steve Kemp
996e7d7e1f Don't abort if the file exists 2008-11-23 21:11:43 +00:00
Steve Kemp
97d01456a3 Attempt to fixup image-dev 2008-11-23 13:13:38 +00:00
Steve Kemp
aa7a2c4c5e New command line argument --no-hosts 2008-11-23 13:06:24 +00:00
Steve Kemp
3522a919ce Allow command line flags to be unset. 2008-10-14 22:04:40 +01:00
Steve Kemp
ef3a15c16c Updated standards version 2008-10-13 19:24:01 +01:00
Steve Kemp
c85144de0f Sync 2008-10-13 19:23:15 +01:00
Steve Kemp
455c16cefe Abort if the generated configuration file already exists.
(Closes: #499475)
2008-10-13 19:18:05 +01:00
Steve Kemp
290a30b1b1 Record the arch for rpm-based distros. Closes: 475125 2008-10-13 19:14:47 +01:00
Steve Kemp
8e2f1236fb Don't test for the POSIX module; per http://www.perlmonks.org/?node_id=689911 2008-06-03 21:49:44 +01:00
Steve Kemp
15436cc018 Correctly sort custom partitions.
#477334
2008-04-30 19:06:36 +01:00
Steve Kemp
3717d0cc15 Correctly force purging of packages in the role script(s).
#477629
2008-04-30 19:05:54 +01:00
Steve Kemp
5d11b820b7 Add the hostname to dom0's /etc/hosts in the correct order.
#477775
2008-04-30 19:05:21 +01:00
Steve Kemp
161ee94632 Add /dev/pts to the fedora guests. #474919 2008-04-30 19:04:04 +01:00
Steve Kemp
9ff14a400e Updated with the debian release 2008-04-30 19:02:51 +01:00
Steve Kemp
cb77db18b9 added perltidy rule 2008-04-01 20:52:15 +01:00
Steve Kemp
8be8f39add Ran through perltidy 2008-04-01 20:52:08 +01:00
Steve Kemp
be30692061 Only show the install source if there is one. 2008-03-14 12:12:28 +00:00
Steve Kemp
7a6c7f17c9 Fixed bug where quote characters prevented interpolation.
Added naive test case to catch the error next time round..
2008-02-20 11:55:32 +00:00
39 changed files with 1767 additions and 1195 deletions

View File

@@ -12,8 +12,9 @@
# #
# Only used to build distribution tarballs. # Only used to build distribution tarballs.
# #
TMP ?= /tmp
DIST_PREFIX = ${TMP} DIST_PREFIX = ${TMP}
VERSION = 3.9 VERSION = 4.1
BASE = xen-tools BASE = xen-tools
@@ -56,7 +57,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 \{\} \;
@find man -name '*.html' -exec rm \{\} \; @if [ -d man ]; then rm -rf man ; fi
@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
@@ -158,6 +159,8 @@ 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/
@@ -193,6 +196,7 @@ 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
@@ -200,7 +204,7 @@ manpages:
# #
# Make a new release tarball, and make a GPG signature. # Make a new release tarball, and make a GPG signature.
# #
release: fixup-perms update-version update-modules clean changelog release: tidy 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)
@@ -228,6 +232,17 @@ 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.
# #

File diff suppressed because it is too large Load Diff

View File

@@ -130,7 +130,7 @@ $CONFIG{'template'} = '/etc/xen-tools/xm-nfs.tmpl';
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
# store version number away. # store version number away.
@@ -243,6 +243,7 @@ sub readConfigurationFile
# command expansion? # command expansion?
if ( $val =~ /(.*)`([^`]+)`(.*)/ ) if ( $val =~ /(.*)`([^`]+)`(.*)/ )
{ {
# store # store
my $pre = $1; my $pre = $1;
my $cmd = $2; my $cmd = $2;
@@ -344,6 +345,7 @@ sub parseCommandLineArguments
sub testArguments sub testArguments
{ {
# #
# Hostname is mandatory # Hostname is mandatory
# #
@@ -381,7 +383,6 @@ 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
@@ -393,6 +394,7 @@ 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.
# #
@@ -408,7 +410,8 @@ sub setupAdminUsers
# #
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" if ( -x "/usr/bin/local/xen-login-shell" ); $shell = "/usr/local/bin/xen-login-shell"
if ( -x "/usr/bin/local/xen-login-shell" );
return if ( !defined($shell) ); return if ( !defined($shell) );
@@ -419,6 +422,7 @@ 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+$//;
@@ -429,12 +433,14 @@ 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 );
@@ -443,8 +449,10 @@ sub setupAdminUsers
# #
# Add the entry to /etc/sudoers. # Add the entry to /etc/sudoers.
# #
open( SUDOERS, ">>", "/etc/sudoers" ) or warn "Failed to add user to sudoers file : $user - $!"; open( SUDOERS, ">>", "/etc/sudoers" )
print SUDOERS "$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n"; or warn "Failed to add user to sudoers file : $user - $!";
print SUDOERS
"$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n";
close(SUDOERS); close(SUDOERS);
} }
@@ -461,7 +469,8 @@ sub setupAdminUsers
sub createNewConfigurationFile sub createNewConfigurationFile
{ {
die "Template file missing: $CONFIG{'template'}" unless( -e $CONFIG{'template'} ); die "Template file missing: $CONFIG{'template'}"
unless ( -e $CONFIG{'template'} );
# #
# Load the template. # Load the template.

View File

@@ -169,8 +169,7 @@ my %CONFIG;
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
@@ -252,7 +251,6 @@ exit 0;
=begin doc =begin doc
Read the configuration file specified. Read the configuration file specified.
@@ -305,6 +303,7 @@ sub readConfigurationFile
# command expansion? # command expansion?
if ( $val =~ /(.*)`([^`]+)`(.*)/ ) if ( $val =~ /(.*)`([^`]+)`(.*)/ )
{ {
# store # store
my $pre = $1; my $pre = $1;
my $cmd = $2; my $cmd = $2;
@@ -328,7 +327,6 @@ sub readConfigurationFile
=begin doc =begin doc
Parse the arguments specified upon the command line. Parse the arguments specified upon the command line.
@@ -388,6 +386,7 @@ 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.
# #
@@ -422,7 +421,6 @@ sub checkArguments
=begin doc =begin doc
Test to see if the given instance is running. Test to see if the given instance is running.
@@ -442,7 +440,7 @@ sub xenRunning
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);
@@ -516,6 +514,7 @@ sub deleteXenImage
} }
elsif ( defined( $CONFIG{'lvm'} ) ) elsif ( defined( $CONFIG{'lvm'} ) )
{ {
# #
# LVM volumes # LVM volumes
# #
@@ -538,6 +537,7 @@ sub deleteXenImage
} }
elsif ( defined( $CONFIG{'evms'} ) ) elsif ( defined( $CONFIG{'evms'} ) )
{ {
# #
# EVMS volumes # EVMS volumes
# #
@@ -596,6 +596,7 @@ 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.
# #

View File

@@ -102,7 +102,7 @@ $CONFIG{'prefix'} = "/etc/xen";
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
@@ -199,6 +199,7 @@ sub readConfigurationFile
# command expansion? # command expansion?
if ( $val =~ /(.*)`([^`]+)`(.*)/ ) if ( $val =~ /(.*)`([^`]+)`(.*)/ )
{ {
# store # store
my $pre = $1; my $pre = $1;
my $cmd = $2; my $cmd = $2;
@@ -221,7 +222,6 @@ sub readConfigurationFile
=begin doc =begin doc
Parse the arguments specified upon the command line. Parse the arguments specified upon the command line.
@@ -238,12 +238,8 @@ sub parseCommandLineArguments
# Parse options. # Parse options.
# #
GetOptions( GetOptions( "test=s", \$CONFIG{'prefix'}, "help", \$HELP, "manual",
"test=s", \$CONFIG{'prefix'}, \$MANUAL, "version", \$VERSION );
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
);
pod2usage(1) if $HELP; pod2usage(1) if $HELP;
pod2usage( -verbose => 2 ) if $MANUAL; pod2usage( -verbose => 2 ) if $MANUAL;

View File

@@ -107,8 +107,6 @@ use Text::Template;
# #
# Configuration values read from the command line, or configuration file. # Configuration values read from the command line, or configuration file.
# #
@@ -118,7 +116,7 @@ my %CONFIG;
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
@@ -147,6 +145,7 @@ my $path = undef;
if ( $CONFIG{'dir'} ) if ( $CONFIG{'dir'} )
{ {
# #
# Make sure we can find the disk # Make sure we can find the disk
# #
@@ -205,6 +204,7 @@ EOF
} }
elsif ( $CONFIG{'lvm'} ) elsif ( $CONFIG{'lvm'} )
{ {
# #
# Make sure we can find the disk # Make sure we can find the disk
# #
@@ -340,6 +340,7 @@ sub readConfigurationFile
# command expansion? # command expansion?
if ( $val =~ /(.*)`([^`]+)`(.*)/ ) if ( $val =~ /(.*)`([^`]+)`(.*)/ )
{ {
# store # store
my $pre = $1; my $pre = $1;
my $cmd = $2; my $cmd = $2;
@@ -442,6 +443,7 @@ sub parseCommandLineArguments
sub testArguments sub testArguments
{ {
# #
# Make sure we received a hostname. # Make sure we received a hostname.
# #
@@ -537,7 +539,7 @@ sub xenRunning
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);

View File

@@ -120,7 +120,7 @@ my %CONFIG;
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
# #
@@ -212,6 +212,7 @@ 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";
@@ -225,6 +226,7 @@ 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";
@@ -239,6 +241,7 @@ sub updateXenImage
} }
elsif ( $CONFIG{'evms'} ) elsif ( $CONFIG{'evms'} )
{ {
# The EVMS volume -- note, unlike LVM, you don't need the $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 # 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 # the underlying object. Still, I don't want to mess with the parse code and
@@ -276,9 +279,10 @@ 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.
# #
@@ -288,7 +292,9 @@ sub updateXenImage
# #
# Now upgrade # Now upgrade
# #
system( "DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes" ); system(
"DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes"
);
} }
else else
{ {
@@ -306,8 +312,6 @@ sub updateXenImage
=begin doc =begin doc
Test to see if the given instance is running. Test to see if the given instance is running.
@@ -327,7 +331,7 @@ sub xenRunning
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);
@@ -336,7 +340,6 @@ sub xenRunning
=begin doc =begin doc
Read the configuration file specified. Read the configuration file specified.
@@ -389,6 +392,7 @@ sub readConfigurationFile
# command expansion? # command expansion?
if ( $val =~ /(.*)`([^`]+)`(.*)/ ) if ( $val =~ /(.*)`([^`]+)`(.*)/ )
{ {
# store # store
my $pre = $1; my $pre = $1;
my $cmd = $2; my $cmd = $2;
@@ -412,7 +416,6 @@ sub readConfigurationFile
=begin doc =begin doc
Parse the arguments specified upon the command line. Parse the arguments specified upon the command line.
@@ -430,12 +433,9 @@ 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'}, "help", \$HELP,
"evms=s", \$CONFIG{'evms'}, "manual", \$MANUAL, "version", \$VERSION
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION
); );
pod2usage(1) if $HELP; pod2usage(1) if $HELP;
@@ -468,6 +468,7 @@ 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.
# #

View File

@@ -156,8 +156,7 @@ $CONFIG{'template'} = '/etc/xen-tools/xm.tmpl';
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
@@ -189,9 +188,6 @@ 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".
@@ -200,9 +196,6 @@ exit 0;
=begin doc =begin doc
Parse the command line arguments this script was given. Parse the command line arguments this script was given.
@@ -260,6 +253,7 @@ sub parseCommandLineArguments
sub checkArguments sub checkArguments
{ {
# #
# We require an output location. # We require an output location.
# #
@@ -274,7 +268,8 @@ sub checkArguments
# #
if ( !-d $CONFIG{'output'} ) if ( !-d $CONFIG{'output'} )
{ {
print "The output directory we've been given, $CONFIG{'output'}, doesnt exist\n"; print
"The output directory we've been given, $CONFIG{'output'}, doesnt exist\n";
print "Aborting\n"; print "Aborting\n";
exit 1; exit 1;
} }
@@ -286,7 +281,8 @@ sub checkArguments
{ {
if ( !-e $CONFIG{'template'} ) if ( !-e $CONFIG{'template'} )
{ {
print "The specified template file, $CONFIG{'template'} does not exist.\n"; print
"The specified template file, $CONFIG{'template'} does not exist.\n";
exit 1; exit 1;
} }
} }
@@ -313,7 +309,8 @@ sub importPartitionsFromEnvironment
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( @PARTITIONS, push(
@PARTITIONS,
{ {
'name' => $parts[0], 'name' => $parts[0],
'size' => $parts[1], 'size' => $parts[1],
@@ -341,6 +338,7 @@ sub importPartitionsFromEnvironment
sub createXenConfig sub createXenConfig
{ {
# #
# The output file we're going to process. # The output file we're going to process.
# #
@@ -475,7 +473,6 @@ sub createXenConfig
=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
@@ -487,6 +484,7 @@ 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.
# #
@@ -502,7 +500,8 @@ sub setupAdminUsers
# #
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" if ( -x "/usr/bin/local/xen-login-shell" ); $shell = "/usr/local/bin/xen-login-shell"
if ( -x "/usr/bin/local/xen-login-shell" );
return if ( !defined($shell) ); return if ( !defined($shell) );
@@ -513,6 +512,7 @@ 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,12 +523,14 @@ 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 );
@@ -537,8 +539,10 @@ sub setupAdminUsers
# #
# Add the entry to /etc/sudoers. # Add the entry to /etc/sudoers.
# #
open( SUDOERS, ">>", "/etc/sudoers" ) or warn "Failed to add user to sudoers file : $user - $!"; open( SUDOERS, ">>", "/etc/sudoers" )
print SUDOERS "$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n"; or warn "Failed to add user to sudoers file : $user - $!";
print SUDOERS
"$user ALL = NOPASSWD: /usr/sbin/xm, /usr/bin/xen-create-image\n";
close(SUDOERS); close(SUDOERS);
} }

View File

@@ -97,8 +97,7 @@ my %CONFIG;
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
@@ -128,9 +127,6 @@ exit 0;
=begin doc =begin doc
Parse the command line arguments this script was given. Parse the command line arguments this script was given.
@@ -186,6 +182,7 @@ sub parseCommandLineArguments
sub checkArguments sub checkArguments
{ {
# #
# We require a location. # We require a location.
# #
@@ -262,6 +259,7 @@ E_OR
sub runDistributionHooks sub runDistributionHooks
{ {
# #
# Hook directory. # Hook directory.
# #
@@ -290,6 +288,7 @@ 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 =~ /~$/ );
@@ -299,6 +298,7 @@ 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.
# #

View File

@@ -113,7 +113,7 @@ my %CONFIG;
# #
# Release number. # Release number.
# #
my $RELEASE = '3.9'; my $RELEASE = '4.1';
# #
@@ -127,36 +127,29 @@ my $RELEASE = '3.9';
# 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" => {
"copy" =>
{
sub => \&do_copy, sub => \&do_copy,
needBinary => "/bin/cp", needBinary => "/bin/cp",
needDirectory => 1, needDirectory => 1,
}, },
"debootstrap" => "debootstrap" => {
{
sub => \&do_debootstrap, sub => \&do_debootstrap,
needBinary => "/usr/sbin/debootstrap", needBinary => "/usr/sbin/debootstrap",
}, },
"image-server" => "image-server" => {
{
sub => \&do_image_server, sub => \&do_image_server,
needURL => 1, needURL => 1,
}, },
"rinse" => "rinse" => {
{
sub => \&do_rinse, sub => \&do_rinse,
needBinary => "/usr/bin/rinse", needBinary => "/usr/bin/rinse",
}, },
"rpmstrap" => "rpmstrap" => {
{
sub => \&do_rpmstrap, sub => \&do_rpmstrap,
needBinary => "/usr/bin/rpmstrap", needBinary => "/usr/bin/rpmstrap",
}, },
"tar" => "tar" => {
{
sub => \&do_tar, sub => \&do_tar,
needBinary => "/bin/tar", needBinary => "/bin/tar",
needFile => 1, needFile => 1,
@@ -165,8 +158,6 @@ my %dispatch =
# #
# Read the global configuration file. # Read the global configuration file.
# #
@@ -206,8 +197,8 @@ 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'} ) )
{ {
# #
@@ -217,48 +208,54 @@ if ( defined( $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 "The following required binary for the installation was not found\n"; print
"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 "The specified directory $CONFIG{'install-source'} does not exist.\n"; print
"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 "The specified file $CONFIG{'install-source'} does not exist.\n"; print
"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 ( ( $installer->{'needURL'} ) && if (
( ! $CONFIG{'install-source'} || ( $installer->{'needURL'} )
( $CONFIG{'install-source'} !~ /^http/i ) ) ) && ( !$CONFIG{'install-source'}
|| ( $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;
@@ -306,10 +303,6 @@ 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
@@ -367,6 +360,7 @@ sub readConfigurationFile
# command expansion? # command expansion?
if ( $val =~ /(.*)`([^`]+)`(.*)/ ) if ( $val =~ /(.*)`([^`]+)`(.*)/ )
{ {
# store # store
my $pre = $1; my $pre = $1;
my $cmd = $2; my $cmd = $2;
@@ -408,6 +402,7 @@ sub parseCommandLineArguments
# Parse options. # Parse options.
# #
GetOptions( GetOptions(
# Mandatory # Mandatory
"location=s", \$CONFIG{'location'}, "location=s", \$CONFIG{'location'},
"dist=s", \$CONFIG{'dist'}, "dist=s", \$CONFIG{'dist'},
@@ -459,6 +454,7 @@ sub parseCommandLineArguments
sub checkArguments sub checkArguments
{ {
# #
# We require a location. # We require a location.
# #
@@ -524,7 +520,8 @@ E_OR
{ {
foreach my $recognised ( keys %dispatch ) foreach my $recognised ( keys %dispatch )
{ {
$valid = 1 if ( lc($CONFIG{'install-method'}) eq lc($recognised) ); $valid = 1
if ( lc( $CONFIG{'install-method'} ) eq lc($recognised) );
} }
} }
else else
@@ -552,7 +549,6 @@ 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
@@ -600,7 +596,6 @@ sub runCommand
=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
@@ -642,8 +637,6 @@ sub copyDebFiles
### ###
# #
# Installation functions follow. # Installation functions follow.
@@ -652,7 +645,6 @@ sub copyDebFiles
=begin doc =begin doc
Install a new image of a distribution using `cp`. Install a new image of a distribution using `cp`.
@@ -663,6 +655,7 @@ 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.
# #
@@ -687,7 +680,6 @@ sub do_copy
=begin doc =begin doc
Install a new image of Debian using 'debootstrap'. Install a new image of Debian using 'debootstrap'.
@@ -698,6 +690,7 @@ 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.
@@ -718,7 +711,8 @@ sub do_debootstrap
{ {
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", "$CONFIG{'location'}/var/cache/apt/archives" ); copyDebFiles( "/var/cache/apt/archives",
"$CONFIG{'location'}/var/cache/apt/archives" );
print("Done\n"); print("Done\n");
} }
@@ -736,14 +730,15 @@ 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 = "$cmd $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $CONFIG{'mirror'}"; my $command =
"$cmd $EXTRA $CONFIG{'dist'} $CONFIG{'location'} $CONFIG{'mirror'}";
# #
# Run the command. # Run the command.
@@ -768,7 +763,6 @@ sub do_debootstrap
=begin doc =begin doc
Install a system using the image-server. Install a system using the image-server.
@@ -781,6 +775,7 @@ sub do_debootstrap
sub do_image_server sub do_image_server
{ {
# #
# Load the modules we require. # Load the modules we require.
# #
@@ -827,6 +822,7 @@ sub do_image_server
# #
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};
@@ -883,17 +879,20 @@ sub do_image_server
# #
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'} . "/$session.tar" ":content_file" => $CONFIG{'location'}
); . "/$session.tar" );
# #
# If it worked .. then untar, remove, and return. # If it worked .. then untar, remove, and return.
# #
system( "cd $CONFIG{'location'} && tar --numeric-owner -xf $session.tar && rm -f $CONFIG{'location'}/$session.tar" ); system(
"cd $CONFIG{'location'} && tar --numeric-owner -xf $session.tar && rm -f $CONFIG{'location'}/$session.tar"
);
return 1; return 1;
} }
} }
@@ -907,20 +906,21 @@ sub do_image_server
} }
else else
{ {
print( "ERROR: Failed to find session. Received this:\n$content\n" ); print(
"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" . $response->status_line ); print( "ERROR: Submitting the image create request failed:\n"
. $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,17 +931,19 @@ 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 = "rinse --distribution=$CONFIG{'dist'} --directory=$CONFIG{'location'}"; my $command =
"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'}";
} }
@@ -1001,7 +1003,6 @@ sub do_rpmstrap
=begin doc =begin doc
Install a new image of a distribution using `tar`. Install a new image of a distribution using `tar`.
@@ -1012,6 +1013,7 @@ 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.
# #

59
debian/changelog vendored
View File

@@ -1,3 +1,62 @@
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:

2
debian/control vendored
View File

@@ -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.7.3 Standards-Version: 3.8.0
Homepage: http://xen-tools.org/software/xen-tools Homepage: http://xen-tools.org/software/xen-tools
Package: xen-tools Package: xen-tools

View File

@@ -248,17 +248,17 @@ reiser_options = defaults
# #
# If you're using a newer version of the Xen guest kernel you will # If you're using the lenny or later version of the Xen guest kernel you will
# need to make sure that you use 'xvc0' for the guest serial device, # need to make sure that you use 'hvc0' 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 = tty1 #default # serial_device = hvc0 #default
# serial_device = xvc0 # serial_device = tty1
# #
# disk_device = sda #default # disk_device = xvda #default
# disk_device = xvda # disk_device = sda
# #

View File

@@ -6,23 +6,31 @@
# #
# Kernel + memory size # Kernel + memory size
# #
{ if ( $kernel ) { if ( ( $kernel ) && ( !defined($pygrub)) )
{ {
$OUT.= "kernel = '$kernel'"; $OUT.= "kernel = '$kernel'";
} }
} }
{ if ( $initrd ) { if ( ( $initrd ) && ( !defined($pygrub)) )
{ {
$OUT.= "ramdisk = '$initrd'"; $OUT.= "ramdisk = '$initrd'";
} }
} }
{
if ( $pygrub )
{
$OUT .= "bootloader = '/usr/bin/pygrub'\n";
}
}
memory = '{$memory}' memory = '{$memory}'
# #
# Disk device(s). # Disk device(s).
# #
{ {
for ( my $i = 0; $i <= $#PARTITIONS; $i++ ) if ( !defined($image_vbd ) )
{
for ( my $i = $#PARTITIONS; $i >= 0 ; $i-- )
{ {
if ( $PARTITIONS[$i]{'mountpoint'} eq '/' ) if ( $PARTITIONS[$i]{'mountpoint'} eq '/' )
{ {
@@ -30,12 +38,43 @@ memory = '{$memory}'
} }
} }
$OUT .= "disk = [\n"; $OUT .= "disk = [\n";
for ( my $i = 0; $i <= $#PARTITIONS; $i++ ) for ( my $i = $#PARTITIONS; $i >= 0 ; $i-- )
{ {
$OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n"; $OUT .= " '$PARTITIONS[$i]{'imagetype'}$PARTITIONS[$i]{'image'},$device" . ( $i + 1 ) .",w',\n";
} }
$OUT .= " ]\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
@@ -69,8 +108,16 @@ name = '{$hostname}'
$m = ",mac=$mac" $m = ",mac=$mac"
} }
my $vn = '';
if ( $vifname )
{
$vn = ",vifname=$vifname";
}
$OUT .= "vif = [ 'ip=$ip1"; $OUT .= "vif = [ 'ip=$ip1";
$OUT .= "$m' ]"; $OUT .= "$m";
$OUT .= "$vn";
$OUT .= "' ]";
} }
} }

44
hooks/centos-4/15-setup-arch Executable file
View File

@@ -0,0 +1,44 @@
#!/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

View File

@@ -89,9 +89,12 @@ 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
# #
@@ -110,6 +113,7 @@ if [ -z "${dhcp}" ]; then
fi fi
fi fi
fi fi
fi
# #

View File

@@ -64,6 +64,7 @@ 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}}\""

44
hooks/centos-5/15-setup-arch Executable file
View File

@@ -0,0 +1,44 @@
#!/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

View File

@@ -89,10 +89,10 @@ 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} ${hostname} ${name}" >> /etc/hosts
echo "${ip1} ${name} ${hostname}" >> /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
@@ -110,6 +110,7 @@ if [ -z "${dhcp}" ]; then
fi fi
fi fi
fi fi
fi
# #

View File

@@ -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 --purge "$@" chroot ${prefix} /usr/bin/apt-get remove --yes --purge "$@"
} }

View File

@@ -89,9 +89,10 @@ if [ -z "${dhcp}" ]; then
# #
name=`echo ${hostname} | awk -F. '{print $1}'` name=`echo ${hostname} | awk -F. '{print $1}'`
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host if [ -z "${nohosts}" ]; then
echo "${ip1} ${name} ${hostname}" >> /etc/hosts logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
# #
@@ -105,12 +106,12 @@ if [ -z "${dhcp}" ]; 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 fi
fi
# #

View File

@@ -61,6 +61,7 @@ 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}}\""

View File

@@ -82,7 +82,7 @@ setupStaticNetworking ()
# #
bcast=''; bcast='';
if [ ! -z "${broadcast}" ]; then if [ ! -z "${broadcast}" ]; then
bcast=' broadcast ${broadcast}' bcast=" broadcast ${broadcast}"
fi fi
# #

View File

@@ -89,9 +89,10 @@ if [ -z "${dhcp}" ]; then
# #
name=`echo ${hostname} | awk -F. '{print $1}'` name=`echo ${hostname} | awk -F. '{print $1}'`
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host if [ -z "${nohosts}" ]; then
echo "${ip1} ${name} ${hostname}" >> /etc/hosts logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
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
@@ -104,12 +105,12 @@ if [ -z "${dhcp}" ]; 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 fi
fi
# #

View File

@@ -60,6 +60,7 @@ 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}}\""

View File

@@ -41,7 +41,8 @@ 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 /etc/apt/apt.conf.d/* ; do for i in /etc/apt/apt.conf $(run-parts --list /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.)
@@ -52,7 +53,8 @@ for i in /etc/apt/apt.conf /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

View File

@@ -42,7 +42,10 @@ 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/inittab sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/event.d/${serial_device}
[ -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

View File

@@ -72,7 +72,7 @@ setupStaticNetworking ()
# #
bcast=''; bcast='';
if [ ! -z "${broadcast}" ]; then if [ ! -z "${broadcast}" ]; then
bcast=' broadcast ${broadcast}' bcast=" broadcast ${broadcast}"
fi fi
# #

View File

@@ -88,9 +88,10 @@ if [ -z "${dhcp}" ]; then
# #
name=`echo ${hostname} | awk -F. '{print $1}'` name=`echo ${hostname} | awk -F. '{print $1}'`
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host if [ -z "${nohosts}" ]; then
echo "${ip1} ${name} ${hostname}" >> /etc/hosts logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
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
@@ -103,12 +104,12 @@ if [ -z "${dhcp}" ]; 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 fi
fi
# #

View File

@@ -61,6 +61,7 @@ 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}}\""

View File

@@ -0,0 +1,44 @@
#!/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

View File

@@ -89,9 +89,10 @@ if [ -z "${dhcp}" ]; then
# #
name=`echo ${hostname} | awk -F. '{print $1}'` name=`echo ${hostname} | awk -F. '{print $1}'`
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host if [ -z "${nohosts}" ]; then
echo "${ip1} ${name} ${hostname}" >> /etc/hosts logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
echo "${ip1} ${hostname} ${name}" >> /etc/hosts
# #
@@ -110,6 +111,7 @@ if [ -z "${dhcp}" ]; then
fi fi
fi fi
fi fi
fi
# #

View File

@@ -64,6 +64,7 @@ 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}}\""

View File

@@ -96,9 +96,10 @@ if [ -z "${dhcp}" ]; then
# #
name=`echo ${hostname} | awk -F. '{print $1}'` name=`echo ${hostname} | awk -F. '{print $1}'`
logMessage Adding ${hostname} and ${name} to /etc/hosts on the host if [ -z "${nohosts}" ]; then
echo "${ip1} ${name} ${hostname}" >> /etc/hosts logMessage Adding ${hostname} and ${name} to /etc/hosts on the host
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
@@ -111,12 +112,12 @@ if [ -z "${dhcp}" ]; 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 fi
fi
# #

View File

@@ -61,6 +61,7 @@ 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}}\""

41
roles/puppet Executable file
View File

@@ -0,0 +1,41 @@
#!/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

View File

@@ -25,7 +25,7 @@ use Test::More qw( no_plan );
EOF EOF
for i in `rgrep '^use ' .. | grep -v Expect | grep -v Xen:: | grep -v Moose | awk '{print $2}' | tr -d for i in `rgrep '^use ' .. | grep -v Expect | grep -v POSIX | 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' ); }"; \

View File

@@ -58,10 +58,6 @@ 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' );

78
t/quoted-strings.t Executable file
View File

@@ -0,0 +1,78 @@
#!/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 );
}