1
0
mirror of synced 2026-02-22 06:37:35 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Axel Beckert
9a81f9ddb5 Pass a hint that further guessing may be necessary 2010-05-28 00:04:55 +02:00
Axel Beckert
e1a620237a Determine which partitions to delete (doesn't delete them yet) 2010-05-28 00:03:54 +02:00
106 changed files with 1753 additions and 2154 deletions

40
.gitignore vendored
View File

@@ -1,31 +1,11 @@
# Note! Please run 'prove t/gitignore.t' after changing
# this file, to check its coherency
# all dotfiles
.*
# but we _wan't_ those dot-files
!.gitignore
!.hgignore
!.mailmap
# ChangeLog is generated during make
/ChangeLog
# those are generated during debian package build
/build-stamp
/configure-stamp
/man
/debian/files
/debian/xen-tools
/debian/xen-tools.debhelper.log
/debian/xen-tools.substvars
# git-generated patches
/*.patch
# some backups
.hg
.hgtags
ChangeLog
*~
*.orig
# backups created by "make update-version"
*.bak
build-stamp
configure-stamp
man
debian/files
debian/xen-tools
debian/xen-tools.debhelper.log
debian/xen-tools.substvars

2
.hgtags Normal file
View File

@@ -0,0 +1,2 @@
d75c787add2a7ceb19b30b018d4d16b7317c772d release-4.
6a10240d7c66e2f7df56457708efb9287640bcf4 release-4.1

View File

@@ -1,6 +0,0 @@
Axel Beckert <abe@deuxchevaux.org>
Dmitry Nedospasov <dmitry@nedos.net>
Nathan O'Sullivan <nathan@mammoth.com.au>
Radu Spineanu <radu@debian.org> radu <none@none>
Steve Kemp <steve@steve.org.uk> steve <none@none>
Stéphane Jourdois <sjourdois@gmail.com> <stephane@jourdois.fr>

34
.release Normal file
View File

@@ -0,0 +1,34 @@
#
# Configuration file for 'release', a utility to make release more
# easily:
#
# http://release.repository.steve.org.uk/
#
# Steve
# --
#
#
# Command to run
#
preupload="make release"
#
#
# Pattern for our release tarball.
#
pattern=xen-tools-[0-9].[0-9].tar.gz*
#
# Pattern for our GPG-signature.
#
signature=xen-tools-[0-9].[0-9].tar.gz.asc
#
# Upload location.
#
upload=steve@www.xen-tools.org:/home/www/www.xen-tools.org/htdocs/software/xen-tools/

View File

@@ -1,3 +1,5 @@
Primary Authors
---------------
@@ -41,10 +43,6 @@ Contributions
Kirk Ismay <captain [at] com.netidea>
- Added hook for automatic CFEngine installation.
Stéphane Jourdois <sjourdois [at] com.gmail>
- Fixed a lot of typos and other small bugs
- Fixed the test suite
Sascha Kettler <kettler [at] net.gmx>
- Implemented support for arbitary partitioning schemes.

View File

@@ -1,13 +0,0 @@
KNOWN BUGS in xen-tools
Bugs to fix before a 4.2 release
--------------------------------
* xen-delete-image doesn't remove all logical volumes if --partitions is used.
See the link below for details how to reproduce. Reproducable at
least with --lvm. Thanks to Antoine Benkemoun for reporting.
http://xen-tools.org/pipermail/xen-tools-discuss/2010-May/000757.html
* xen-delete-image ignores extension setting

View File

@@ -17,7 +17,7 @@ DIST_PREFIX = ${TMP}
VERSION = 4.2rc1
DEBVERSION = $(shell echo $(VERSION)|sed 's/\(rc\|pre\|beta\|alpha\)/~\1/')
BASE = xen-tools
VCS = $(shell if git ls-files > /dev/null; then echo git; \
VCS = $(shell if git st > /dev/null; then echo git; \
elif hg st > /dev/null; then echo hg; \
else echo cannot-determine-used-vcs; fi)
@@ -53,17 +53,14 @@ changelog:
# Delete all temporary files, recursively.
#
clean:
@find . \
-path ./.git -prune -o \
\( \
-name '*~' -o \
-name '.#*' -o \
-name '*.bak' -o \
-name '*.tmp' -o \
-name 'tags' -o \
-name '*.8.gz' -o \
-name '*.tdy' \
\) -exec rm "{}" +
@find . -name '.*~' -exec rm \{\} \;
@find . -name '.#*' -exec rm \{\} \;
@find . -name '*~' -exec rm \{\} \;
@find . -name '*.bak' -exec rm \{\} \;
@find . -name '*.tmp' -exec rm \{\} \;
@find . -name 'tags' -exec rm \{\} \;
@find . -name '*.8.gz' -exec rm \{\} \;
@find . -name '*.tdy' -exec rm \{\} \;
@if [ -d man ]; then rm -rf man ; fi
@if [ -e build-stamp ]; then rm -f build-stamp ; fi
@if [ -e configure-stamp ]; then rm -f configure-stamp ; fi
@@ -246,7 +243,7 @@ orig-tar-gz: release
#
# Run the test suite.
#
test: update-modules
test:
prove --shuffle t/
@@ -308,7 +305,7 @@ update:
# cases to ensure that all required modules are available.
#
update-modules:
@cd t && make modules
cd t && make modules
#
@@ -316,4 +313,4 @@ update-modules:
# at the top of this file. Steve-Specific?
#
update-version:
perl -pi.bak -e "s/RELEASE = '[0-9]\.[0-9][^']*';/RELEASE = '${VERSION}';/g" bin/*-*[!~]
perl -pi.bak -e "s/RELEASE = '[0-9]\.[0-9][^']*';/RELEASE = '${VERSION}';/g" bin/*-*[^~]

97
TODO
View File

@@ -1,26 +1,64 @@
TODO
====
See KNOWN_BUGS for real bugs.
Minor bugs to fix and features to add before a 4.2 release
----------------------------------------------------------
Bugs to fix and Features to add before a 4.2 release
----------------------------------------------------
* xen-create-image man page overhaul:
- ambiguous option list with regards to parameters
- Set Fail in more situations where the script has clearly failed
i.e.: lvm exists
* Interactive Password Handling (maybe also the passwd role)
Shouldn't give up after only one password missmatch. This is just
a mater of wrapping the passwd call in a loop.
* Fix 70-install-ssh
Currently 70-install-ssh fails to finish installing the ssh-server
because it does not have a random seed to generate the host keys.
Mounting /proc and /dev in chroot prior to calling the install
function should fix this. If ssh-server is successfully installed
in the domU, it's key fingerprint should be echo'd in a way that
can easily be grep'ed into other scripts.
* Test and support more file system types.
Actually this should be pretty simple now that the parameters are
stored in the configuration hash.
stored in the configuration hash. The only issue is that trailing
whitespace is missing from the "make_fs_foo" option.
* xen-delete-image doesn't remove all logical volumes if --partitions is used.
See the link below for details how to reproduce. Reproducable at
least with --lvm. Thanks to Antoine Benkemoun for reporting.
http://xen-tools.org/pipermail/xen-tools-discuss/2010-May/000757.html
* xen-delete-image ignores extension setting
* xen-create-image should check all integer options on non-digits.
* Test suite should pass
Currently failing:
t/getopt.t
t/xen-delete-image.t
t/xen-tools.t
t/xt-create-xen-config.t
* Clean up setup-hostname - copying /etc/hosts isn't reliable
One could argue that that this gives "extra" information to the domU, since
the /etc/hosts file may contain more than just hosts on the same subnet.
This should atleast be disabled via a flag.
* Setup locales in the hooks?
Currently no locales are set and this causes several domU errors
which appear in the domU's logs.
Currently no locales are set and this causes several domU errors which appear
in the domU's logs.
Maybe for a 4.3 or 5.0 release
------------------------------
@@ -57,22 +95,24 @@ Maybe for a 4.3 or 5.0 release
* Clean up mounts on Ctrl-C, causes error while installing otherwise:
Removing /dev/vg0/acromantula-domu1-disk - since we're forcing the
install Can't remove open logical volume "acromantula-domu1-disk"
this should be a matter of unmounting the mounted volume from /tmp.
Removing /dev/vg0/acromantula-domu1-disk - since we're forcing the install
Can't remove open logical volume "acromantula-domu1-disk" this should be a
matter of unmounting the mounted volume from /tmp.
* Non-Interactive Password Handling
Option to generate passwords (check pwgen, apg, makepasswd, and
gpw which of them are best suited for generating complete
/etc/passwd and /etc/shadow lines). The password should be echo'ed
after installation in a way that can be easily grep'ed into other
scripts.
* Generic grub support
This will generate a much nicer menu.lst as a side effect, as its
currently generated once at install, and is never updated. Installing
a full grub into the domU should update the menu.lst every time a
new kernel is installed and will also use the domU distro's menu.lst
conform.
* pv-grub support
This is a ways away and will probably start with a xen-pv-grub
package.
This will generate a much nicer menu.lst as a side effect, as its currently
generated once at install, and is never updated. Installing a full grub into
the domU should update the menu.lst every time a new kernel is installed and
will also use the domU distro's menu.lst conform.
* Move the hooks directory to /etc/xen-tools/ to officially allow
added and modified hooks.
@@ -100,7 +140,7 @@ Maybe for a 4.3 or 5.0 release
To specify a directory of public keys, parsing the hostnames
parsing the usernames from the ssh comment line
* More generic roles
* More generic hooks
Deploy a web server or setup ssmtp directly via flag when setting up
the machine. Open to suggestions, should just be some general use-cases
@@ -113,17 +153,6 @@ Maybe for a 4.3 or 5.0 release
"type" of configuration you want, and a set of options specific to
that flag could be parsed from xen-tools.conf
* Refactor the code for less code duplication
Like e.g. readConfigurationFile in xen-create-image and
xen-resize-image which are not completely identical.
* Parse numerical parameters transparently for the user
The user shouldn't have to know weather he should specify size
as <size>G or <size>Gb or <size>. This should be parsed without
user interaction and rely on a common format.
Stuff from Steve's TODO list / Generic TODOs
--------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,6 @@ xen-create-nfs - Create a Xen configuration file for an NFS-root guest.
--gateway The gateway address to use when configured with a static IP.
--hostname The hostname to configure for the guest.
--netmask The netmask to use when configured with a static IP.
--nameserver The nameserver to use when configured with a static IP.
--ip The IP address to use when configured with a static IP.
General options:
@@ -289,15 +288,14 @@ sub parseCommandLineArguments
GetOptions(
# Networking options
"dhcp", \$CONFIG{ 'dhcp' },
"gateway=s", \$CONFIG{ 'gateway' },
"broadcast=s", \$CONFIG{ 'broadcast' },
"ip=s", \$CONFIG{ 'ip' },
"netmask=s", \$CONFIG{ 'netmask' },
"nameserver=s", \$CONFIG{ 'nameserver' },
"hostname=s", \$CONFIG{ 'hostname' },
"memory=s", \$CONFIG{ 'memory' },
"mac=s", \$CONFIG{ 'mac' },
"dhcp", \$CONFIG{ 'dhcp' },
"gateway=s", \$CONFIG{ 'gateway' },
"broadcast=s", \$CONFIG{ 'broadcast' },
"ip=s", \$CONFIG{ 'ip' },
"netmask=s", \$CONFIG{ 'netmask' },
"hostname=s", \$CONFIG{ 'hostname' },
"memory=s", \$CONFIG{ 'memory' },
"mac=s", \$CONFIG{ 'mac' },
# NFS options.
"nfs_server=s", \$CONFIG{ 'nfs_server' },

View File

@@ -51,7 +51,7 @@ Specify the LVM volume group where images were previously saved.
Read the manual for this script.
=item B<--test>
Do not complain, or exit, if the script is not executed by the root user.
Don not complain, or exit, if the script is not executed by the root user.
=item B<--version>
Show the version number and exit.
@@ -156,7 +156,6 @@ use strict;
use English;
use Getopt::Long;
use Pod::Usage;
use File::Path;
#
@@ -173,7 +172,6 @@ my %CONFIG;
my $RELEASE = '4.2rc1';
#
# Read the global configuration file if it exists.
#
@@ -221,7 +219,21 @@ while ( my $name = shift )
{
if ( !xenRunning($name) )
{
deleteXenImage($name);
#
# Partition layout information values read from the
# partitions file, or constructed automatically if no
# partitions file is specified.
#
my @PARTITIONS = undef;
#
# Check for partitions to delete by reading the DomU's
# configuration file
#
my @PARTITIONS = findPartitions($host
deleteXenImage($name, @PARTITIONS);
}
else
{
@@ -413,7 +425,7 @@ sub checkArguments
#
if ( $count != 1 )
{
print "Please select one and only one of the installation methods to delete the DomU:\n";
print "Please select one and only one of the installation methods:\n";
print " --dir\n";
print " --evms\n";
print " --lvm\n";
@@ -450,6 +462,70 @@ sub xenRunning
}
=begin doc
Read the (usually to be deleted) DomU configuration file specified
and returns the list of used partitions found in the file.
=end doc
=cut
sub findPartitions
{
my ($hostname) = (@_);
my $file = "/etc/xen/$hostname.cfg";
if ( -e $file )
{
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
my $line = "";
my $contents = "";
while ( defined( $line = <FILE> ) )
{
chomp $line;
if ( $line =~ s/\\$// )
{
$line .= <FILE>;
redo unless eof(FILE);
}
# Skip lines beginning with comments
next if ( $line =~ /^([ \t]*)\#/ );
# Skip blank lines
next if ( length($line) < 1 );
# Strip trailing comments.
if ( $line =~ /(.*)\#(.*)/ )
{
$line = $1;
}
$contents .= $line;
}
close(FILE);
if ($contents =~ /\ndisk\s*=\s*\[\s*(.*?)\s*\]\s*\n/) {
my $disks = $1;
my @disks = split(/\n/, $disks);
foreach (@disks) {
s/^\s*'phy:(.*),\w*,\w*',\s*$/$1/;
}
return @disks;
}
} else {
warn "Couldn't find $file. May start guessing based on further parameters.\n";
return qw(GUESSING);
}
}
=begin doc
Delete the named image, and the corresponding configuration file
@@ -461,7 +537,11 @@ sub xenRunning
sub deleteXenImage
{
my ($hostname) = (@_);
my $hostname = shift;
my @partitions = @_;
my $guessing = ($#partitions == 0 and $partitions[0] eq 'GUESSING');
#
# Collect the names of files to delete.
@@ -518,7 +598,7 @@ sub deleteXenImage
print "Would delete: $prefix$hostname\n";
} else {
print "Removing: " . $prefix . $hostname . "\n";
rmtree( $prefix . $hostname );
rmdir( $prefix . $hostname );
}
}
}

View File

@@ -239,9 +239,7 @@ sub parseCommandLineArguments
# Parse options.
#
GetOptions( "test=s", \$CONFIG{ 'prefix' },
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION );
"help", \$HELP, "manual", \$MANUAL, "version", \$VERSION );
pod2usage(1) if $HELP;
pod2usage( -verbose => 2 ) if $MANUAL;

View File

@@ -301,9 +301,6 @@ sub readConfigurationFile
{
my ($file) = (@_);
# Don't read the file if it doesn't exist.
return if ( !-e $file );
open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
my $line = "";

View File

@@ -105,7 +105,6 @@ The LICENSE file contains the full text of the license.
use strict;
use English;
use File::Temp qw/ tempdir /;
use File::Copy qw/ mv cp /;
use Getopt::Long;
use Pod::Usage;
@@ -288,11 +287,6 @@ sub updateXenImage
if ( ( -e $tmp . "/usr/bin/apt-get" ) &&
( -x $tmp . "/usr/bin/apt-get" ) )
{
#
# Copy dom0's resolv.conf to domU
#
mv("$tmp/etc/resolv.conf", "$tmp/etc/resolv.conf.old") if -f "$tmp/etc/resolv.conf";
cp("/etc/resolv.conf", "$tmp/etc/resolv.conf");
#
# Now run the update command.
@@ -306,15 +300,6 @@ sub updateXenImage
system(
"DEBIAN_FRONTEND=noninteractive chroot $tmp /usr/bin/apt-get upgrade --yes --force-yes"
);
#
# Restore domU's resolv.conf if needed
#
if (-f "$tmp/etc/resolv.conf") {
mv("$tmp/etc/resolv.conf.old", "$tmp/etc/resolv.conf");
} else {
unlink "$tmp/etc/resolv.conf";
}
}
else
{
@@ -452,12 +437,10 @@ sub parseCommandLineArguments
# Parse options.
#
GetOptions( "dir=s", \$CONFIG{ 'dir' },
"lvm=s", \$CONFIG{ 'lvm' },
"evms=s", \$CONFIG{ 'evms' },
"help", \$HELP,
"manual", \$MANUAL,
"version", \$VERSION );
GetOptions( "dir=s", \$CONFIG{ 'dir' }, "lvm=s", \$CONFIG{ 'lvm' },
"evms=s", \$CONFIG{ 'evms' }, "help", \$HELP,
"manual", \$MANUAL, "version", \$VERSION
);
pod2usage(1) if $HELP;
pod2usage( -verbose => 2 ) if $MANUAL;

View File

@@ -151,7 +151,6 @@ my @PARTITIONS = undef;
# Default options
#
$CONFIG{ 'template' } = '/etc/xen-tools/xm.tmpl';
$CONFIG{ 'extension' } = '.cfg';
#
@@ -306,7 +305,6 @@ sub importPartitionsFromEnvironment
{
@PARTITIONS = ();
return unless exists $ENV{ 'NUMPARTITIONS' };
for ( my $i = 1 ; $i <= $ENV{ 'NUMPARTITIONS' } ; $i++ )
{
my @parts = split( /:/, $ENV{ 'PARTITION' . $i }, 7 );
@@ -335,11 +333,12 @@ sub importPartitionsFromEnvironment
sub createXenConfig
{
#
# The output file we're going to process.
#
my $file =
$CONFIG{ 'output' } . '/' . $ENV{ 'hostname' } . $CONFIG{ 'extension' };
$CONFIG{ 'output' } . '/' . $ENV{ 'hostname' } . $ENV{ 'extension' };
#
# The template we're going to read from.

View File

@@ -226,12 +226,12 @@ sub checkArguments
{
print <<E_OR;
We\'re trying to configure an installation of $CONFIG{'dist'} in
We're trying to configure an installation of $CONFIG{'dist'} in
$CONFIG{'location'} - but there is no hook directory for us to use.
This means we don\'t know how to configure this installation.
This means we don't know how to configure this installation.
We\'d expect the hook directory to be : $dir
We'd expect the hook directory to be : $dir
Aborting.
E_OR
@@ -322,9 +322,9 @@ sub runDistributionHooks
print "--\n";
my $rc = system($cmd);
if ($rc != 0) {
print "hook $name failed: $?\n";
exit 1;
}
print "hook $name failed: $?\n";
exit 1;
}
print "--\n";
print "Done\n\n";
}
@@ -333,9 +333,9 @@ sub runDistributionHooks
print "Running hook $name\n";
my $rc = system($cmd);
if ($rc != 0) {
print "hook $name failed: $?\n";
exit 1;
}
print "hook $name failed: $?\n";
exit 1;
}
print "hook $name: done.\n";
}
}

View File

@@ -2,29 +2,25 @@
=head1 NAME
xt-guess-suite-and-mirror - Tries to guess the most suitable suite and
mirror for DomUs on Debian and Ubuntu Dom0s.
xen-guess-debian-mirror - Tries to guess the most suitable mirror and
suite for DomUs on Debian and Ubuntu Dom0s.
=cut
=head1 SYNOPSIS
--suite Show suite
--mirror Show mirror
xen-guess-debian-mirror [-s] [-m]
-s show suite
-m show mirror
Shows both if no parameter is given.
Help Options:
--help Show the help information for this script.
--manual Show the manual for this script.
--version Show the version number and exit.
=cut
=head1 DESCRIPTION
xt-guess-suite-and-mirror tries to find the mirror and suite the Xen
xen-guess-debian-mirror tries to find the mirror and suite the Xen
Dom0 is currently using and returns them in a way suitable for
xen-create-image(1) or the backticks feature in xen-tools.conf.
@@ -53,9 +49,8 @@ full text of the license.
# Fallback to Debian or Ubuntu in case we can't find anything
my $fallback = 'Debian';
# Which mirrors to use if everything else fails (cdn.debian.net uses
# GeoIP, see http://wiki.debian.org/DebianGeoMirror)
my %fallback_mirror = ( Debian => 'http://cdn.debian.net/debian/',
# Which mirrors to use if everything else fails
my %fallback_mirror = ( Debian => 'http://ftp.debian.org/debian/',
Ubuntu => 'http://archive.ubuntu.com/ubuntu/' );
# Which suite to use if everything else fails. For Debian "stable"
@@ -90,20 +85,21 @@ my $want_mirror = 0;
my $want_suite = 0;
my $want_version = 0;
my $want_help = 0;
my $want_manual = 0;
my $want_usage = 0;
my $result = GetOptions( 'mirror|m' => \$want_mirror,
'suite|s' => \$want_suite,
'version' => \$want_version,
'manual' => \$want_manual,
'help' => \$want_help );
my $result = GetOptions ('mirror' => \$want_mirror,
'suite' => \$want_suite,
'version' => \$want_version,
'usage' => \$want_usage,
'help' => \$want_help);
if ($want_help) {
pod2usage(0);
print "Usage: $0 [-m] [-s]\n";
exit 0;
}
if ($want_manual) {
pod2usage( -verbose => 2 );
if ($want_usage) {
pod2usage(0);
}
if (-r $sources_list_file) {

View File

@@ -245,6 +245,17 @@ if ( defined( $CONFIG{ 'install-method' } ) &&
exit 1;
}
# Do we need an URL specified as the installation source?
if ( ( $installer->{ 'needURL' } ) &&
( !$CONFIG{ 'install-source' } ||
( $CONFIG{ 'install-source' } !~ /^http/i ) ) )
{
print "Please specify the image server URL with --install-source\n";
exit 1;
}
#
# Now we can call the appropriate handler.
#
@@ -255,9 +266,16 @@ if ( defined( $CONFIG{ 'install-method' } ) &&
#
# Test that we have some "standard" files present.
#
checkForCommonFilesInChroot($CONFIG{ 'location' },
"installed system");
foreach my $file (qw( /bin/ls /bin/cp ))
{
if ( !-x $CONFIG{ 'location' } . $file )
{
print "The installation of the new system has failed.\n";
print "\n";
print "The system is missing the common file: $file\n";
exit 1;
}
}
#
# All done.
@@ -391,7 +409,6 @@ sub parseCommandLineArguments
# Misc
"arch=s", \$CONFIG{ 'arch' },
"cache=s", \$CONFIG{ 'cache' },
"cachedir=s", \$CONFIG{ 'cachedir' },
"config=s", \$CONFIG{ 'config' },
"mirror=s", \$CONFIG{ 'mirror' },
@@ -526,30 +543,6 @@ EOF
=begin doc
Check if there are some common files in some chroot
=end doc
=cut
sub checkForCommonFilesInChroot {
my ($chroot, $what) = @_;
foreach my $file (qw( /bin/ls /bin/cp ))
{
if ( !-x $chroot.$file )
{
print STDERR <<EOT;
WARNING ($0): The $what at $chroot doesn\'t seem to be a full system.
WARNING ($0): The $what is missing the common file: $file.
EOT
}
}
}
=begin doc
A utility method to run a system command. We will capture the return
@@ -657,12 +650,6 @@ sub copyDebFiles
sub do_copy
{
#
# Check if the copy source has at least some "standard" files present.
#
checkForCommonFilesInChroot($CONFIG{ 'install-source' },
"installation source");
#
# Find the copy command to run from the configuration file.
#
@@ -703,18 +690,17 @@ sub do_debootstrap
# to use cdebootstrap.
#
my $cmd = $CONFIG{ 'debootstrap-cmd' };
my $cachedir = $CONFIG{ 'cachedir' };
if ( !$cmd )
{
if (-x '/usr/sbin/debootstrap') {
$cmd = '/usr/sbin/debootstrap';
} elsif (-x '/usr/sbin/cdebootstrap') {
$cmd = '/usr/sbin/cdebootstrap';
} else {
print STDERR "Found neither debootstrap nor cdebootstrap and no --debootstrap-cmd given\n";
exit 1;
}
print "Using $cmd as debootstrap command\n";
if (-x '/usr/sbin/debootstrap') {
$cmd = '/usr/sbin/debootstrap';
} elsif (-x '/usr/sbin/cdebootstrap') {
$cmd = '/usr/sbin/cdebootstrap';
} else {
print STDERR "Found neither debootstrap nor cdebootstrap and no --debootstrap-cmd given\n";
exit 1;
}
print "Using $cmd as debootstrap command\n";
}
@@ -725,16 +711,8 @@ sub do_debootstrap
if ( $CONFIG{ 'cache' } eq "yes" )
{
print "\nCopying files from host to image.\n";
unless( -d $cachedir ) {
my $xtcache = '/var/cache/xen-tools/archives/';
print("$cachedir not found, defaulting to $xtcache\n");
unless ( -d $xtcache ) {
system "mkdir -p $xtcache";
}
$cachedir = $xtcache;
}
runCommand("mkdir -p $CONFIG{'location'}/var/cache/apt/archives");
copyDebFiles( "$cachedir",
copyDebFiles( "/var/cache/apt/archives",
"$CONFIG{'location'}/var/cache/apt/archives" );
print("Done\n");
}
@@ -777,7 +755,7 @@ sub do_debootstrap
{
print "\nCopying files from new installation to host.\n";
copyDebFiles( "$CONFIG{'location'}/var/cache/apt/archives",
"$cachedir" );
"/var/cache/apt/archives" );
print("Done\n");
}

11
debian/NEWS vendored
View File

@@ -1,14 +1,5 @@
xen-tools (4.2~rc1-1) unstable; urgency=low
By default, xen-create-image now generates a random root password and
displays it as plain text at the end of the DomU generation process.
Use --genpass=0 and --passwd=1 to interactively set a root password
without the password being displayed.
-- Axel Beckert <abe@debian.org> Tue, 03 Aug 2010 16:14:42 +0200
xen-tools (4.2~beta1-1) unstable; urgency=low
If the DomU hangs with "Waiting for root file system" despite
/dev/xvd* is used as disk device, adding "xen-blkfront" to
/etc/initramfs-tools/modules and runing "update-initramfs -u"
@@ -23,5 +14,5 @@ xen-tools (4.2~beta1-1) unstable; urgency=low
/etc/apt/sources.list (if it exists) and taking the first entry with
path ending in /debian/ there.
-- Axel Beckert <abe@debian.org> Sun, 30 May 2010 22:36:16 +0200
-- Axel Beckert <abe@debian.org> Sat, 15 May 2010 18:04:14 +0200

32
debian/changelog vendored
View File

@@ -1,33 +1,8 @@
xen-tools (4.2~rc1-1) unstable; urgency=low
[Axel Beckert]
* New upstream release candidate
- Uses GeoIP for Debian mirrors: Default Debian mirror is now
cdn.debian.net, see http://wiki.debian.org/DebianGeoMirror for
details.
- Uses the same 15-disable-hwclock hook for Debian as for Ubuntu DomUs
(Closes: #588880)
- Mounts not only /proc but also /dev/pts automatically before running
any customisation hooks (Closes: #588783)
- Uses apt-config to parse Dom0's apt.conf. (Closes: #560011)
- Fixes wrong loop module parameter syntax in warning. Thanks to
Daniel Baumann for spotting this. (Closes: #516902)
- With --verbose, the output of commands called by xen-tools
(e.g. debootstrap) is not only logged, but also printed to
STDOUT. (Closes: #513126)
- Adds btrfs support.
* Bump Standards-Version to 3.9.1 (no changes)
[Stéphane Jourdois]
* [debian/control] Suggest btrfs-tools
-- Axel Beckert <abe@debian.org> Sun, 15 Aug 2010 19:34:38 +0200
xen-tools (4.2~beta1-1) unstable; urgency=low
xen-tools (4.2~rc1-1) UNRELEASED; urgency=low
* New maintainer and upstream authors
* Reintroduction into Debian Unstable (Closes: #566714)
* New upstream beta version
* New upstream release candidate
- Needs dependency on libfile-slurp-perl
- Supports for more recent versions of Fedora, Ubuntu and Debian
(Closes: #499477)
@@ -66,7 +41,6 @@ xen-tools (4.2~beta1-1) unstable; urgency=low
- Checks for debootstrap and cdebootstrap, uses debootstrap if both
are installed (Changed "Depends: debootstrap" to "Depends:
debootstrap | cdebootstrap" in debian/control)
- Added new files TODO and KNOWN_BUGS to debian/docs.
* Removal of /etc/bash_completion.d/xm from the package since
bash-completion ships a more elaborate version of that file. (Closes:
#566683, #550590, LP: #538917, #484098)
@@ -91,7 +65,7 @@ xen-tools (4.2~beta1-1) unstable; urgency=low
the Git repository.
* Overhauled package description
-- Axel Beckert <abe@debian.org> Sun, 30 May 2010 22:32:30 +0200
-- Axel Beckert <abe@debian.org> Mon, 17 May 2010 13:32:04 +0200
xen-tools (4.1-1) unstable; urgency=low

4
debian/control vendored
View File

@@ -3,7 +3,7 @@ Section: utils
Priority: extra
Maintainer: Axel Beckert <abe@debian.org>
Build-Depends: debhelper (>= 7.0.0), libtest-pod-perl, libtext-template-perl
Standards-Version: 3.9.1
Standards-Version: 3.8.4
Homepage: http://xen-tools.org/software/xen-tools
Vcs-Browser: http://gitorious.org/xen-tools/xen-tools
Vcs-Git: git://gitorious.org/xen-tools/xen-tools.git
@@ -12,7 +12,7 @@ Package: xen-tools
Architecture: all
Depends: debootstrap | cdebootstrap, perl-modules, libtext-template-perl, libconfig-inifiles-perl, libfile-slurp-perl, ${misc:Depends}
Recommends: xen-hypervisor-amd64 | xen-hypervisor-i386 | xen-hypervisor-i386-pae, rinse, xen-shell, libexpect-perl
Suggests: reiserfsprogs, xfsprogs, xen-utils, cfengine2, evms-cli, btrfs-tools
Suggests: reiserfsprogs, xfsprogs, xen-utils, cfengine2, evms-cli
Description: Tools to manage Xen virtual servers
This package contains tools to manage Debian based Xen virtual servers.
.

1
debian/copyright vendored
View File

@@ -5,7 +5,6 @@ It was downloaded from http://xen-tools.org/software/xen-tools/
Copyright 2005-2009: Steve Kemp <steve@steve.org.uk>
Copyright 2010: Axel Beckert <abe@deuxchevaux.org>
Copyright 2010: Dmitry Nedospasov <dmitry@nedos.net>
License:

3
debian/docs vendored
View File

@@ -2,5 +2,4 @@ AUTHORS
README
SUPPORT
BUGS
TODO
KNOWN_BUGS
TODO

1
debian/rules vendored
View File

@@ -28,7 +28,6 @@ install: build
dh_prep
make manpages
make changelog
make install prefix=`pwd`/debian/xen-tools
dh_installdirs

View File

@@ -107,13 +107,13 @@ install-method = debootstrap
# (This allows you to install from a .tar.bz file, rather than a plain
# tar file, use cdebootstrap, etc.)
#
# install-method = copy:
# install-method=copy:
# copy-cmd = /bin/cp -a $src/* $dest
#
# install-method = debootstrap:
# debootstrap-cmd = /usr/sbin/debootstrap
# install-method=debootstrap:
# debootstrap-cmd=/usr/sbin/debootstrap
#
# install-method = tar:
# install-method=tar:
# tar-cmd = /bin/tar --numeric-owner -xvf $src
#
#
@@ -130,7 +130,7 @@ memory = 128Mb # Memory size
swap = 128Mb # Swap size
# noswap = 1 # Don't use swap at all for the new system.
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = `xt-guess-suite-and-mirror --suite` # Default distribution to install.
dist = `xt-guess-suite-and-mirror -s` # Default distribution to install.
image = sparse # Specify sparse vs. full disk images.
#
@@ -160,30 +160,14 @@ image = sparse # Specify sparse vs. full disk images.
# Uncomment and adjust these network settings if you wish to give your
# new instances static IP addresses.
#
# gateway = 192.168.1.1
# netmask = 255.255.255.0
# broadcast = 192.168.1.255
# gateway = 192.168.1.1
# netmask = 255.255.255.0
# broadcast = 192.168.1.255
#
# Uncomment this if you wish the images to use DHCP
#
# dhcp = 1
#
# Uncomment and adjust this setting if you wish to give your new
# instances a specific nameserver.
#
# By default, nameserver is not set, and Dom0's /etc/resolv.conf will
# be copied to guest.
#
# nameserver = 192.168.1.1
#
#
# Setup bridge name for host vif. Usefull if you use bridged networking
# for guests.
#
# bridge = xendmz
#
##
# Misc options
@@ -197,41 +181,10 @@ image = sparse # Specify sparse vs. full disk images.
#
#
# The default cachedir is, /var/cache/apt/archives/, however if it
# does not exist it will default to /var/cache/xen-tools/archives/
# Uncomment the line below to set it to something else.
#
# cachedir = /var/cache/xen-tools/archives/
#
#
# Uncomment the following line if you wish not to generate a new root
# password for the new guest.
#
# genpass = 0
#
#
# You can also change the password length by uncommenting and
# changing the line below
#
# genpass_len = 8
#
#
# You can yet change the hashing method to encrypt the generated
# password by changing the line below.
# Valid values : md5, sha256 and sha512.
#
# hash_method = sha256
#
#
# Uncomment the following line if you wish to interactively setup a
# new root password for images.
# Uncomment the following line if you wish to interactively setup
# a new root password for images.
#
# passwd = 1
#
#
# If you'd like all accounts on your host system which are not present
@@ -243,8 +196,8 @@ image = sparse # Specify sparse vs. full disk images.
#
# Default kernel and ramdisk to use for the virtual servers
#
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
#
# The architecture to use when using debootstrap, rinse, or rpmstrap.
@@ -252,13 +205,13 @@ initrd = /boot/initrd.img-`uname -r`
# This is most useful on 64 bit host machines, for other systems it
# doesn't need to be used.
#
# arch = [i386|amd64]
# arch=[i386|amd64]
#
#
# The default mirror for debootstrap to install Debian-derived distributions
#
mirror = `xt-guess-suite-and-mirror --mirror`
mirror = `xt-guess-suite-and-mirror -m`
#
# A mirror suitable for use when installing the Dapper release of Ubuntu.
@@ -268,33 +221,24 @@ mirror = `xt-guess-suite-and-mirror --mirror`
#
# If you like you could use per-distribution mirrors, which will
# be more useful if you're working in an environment where you want
# to regularly use multiple distributions. The following are the
# default values used (for Debian the GeoIP feature is used, see
# http://wiki.debian.org/DebianGeoMirror):
# to regularly use multiple distributions:
#
# mirror_sarge = http://archive.debian.org/debian
# mirror_lenny = http://cdn.debian.net/debian
# mirror_squeeze = http://cdn.debian.net/debian
# mirror_sid = http://cdn.debian.net/debian
# mirror_dapper = http://archive.ubuntu.com/ubuntu
# mirror_edgy = http://old-releases.ubuntu.com/ubuntu
# mirror_feisty = http://old-releases.ubuntu.com/ubuntu
# mirror_gutsy = http://old-releases.ubuntu.com/ubuntu
# mirror_hardy = http://archive.ubuntu.com/ubuntu
# mirror_intrepid = http://archive.ubuntu.com/ubuntu
# mirror_karmic = http://archive.ubuntu.com/ubuntu
# mirror_lucid = http://archive.ubuntu.com/ubuntu
# mirror_maverick = http://archive.ubuntu.com/ubuntu
# mirror_sid=http://ftp.us.debian.org/debian
# mirror_sarge=http://ftp.us.debian.org/debian
# mirror_etch=http://ftp.us.debian.org/debian
# mirror_dapper=http://archive.ubuntu.com/ubuntu
# mirror_edgy=http://archive.ubuntu.com/ubuntu
# mirror_feisty=http://archive.ubuntu.com/ubuntu
# mirror_gutsy=http://archive.ubuntu.com/ubuntu
#
# Filesystem options for the different filesystems we support.
#
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiserfs_options = defaults
btrfs_options = defaults
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiser_options = defaults
#
# Uncomment if you wish newly created images to boot once they've been
@@ -330,20 +274,3 @@ btrfs_options = defaults
# output = /etc/xen
# extension = .cfg
#
#
# Here you can control weather your dom0's /etc/hosts file should be
# appended with the new guest, and also if your dom0's /etc/hosts file
# should be copied to the new guest.
#
# Change the following options to 1 to set them
# nohosts - don't touch the dom0's /etc/hosts file
# copyhosts - copy the dom0's /etc/hosts to the guest
#
# by default new guests ARE added to the dom0's /etc/hosts file
# nohosts = 0 # default
#
# by default the dom0's /etc/hosts IS NOT copied
# copyhosts = 0 # default
#

View File

@@ -26,6 +26,11 @@ fi
logMessage Script $0 starting
#
# DNS is probably required to run "yum update".
#
cp /etc/resolv.conf ${prefix}/etc
#
# Update yum
#

View File

@@ -73,19 +73,6 @@ E_O_STATIC
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0

View File

@@ -0,0 +1,58 @@
#!/bin/sh
#
# Copy files from a 'skel' directory, if present, into the
# new images
#
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
#
# Copy "required" files from our host.
#
# NONE DONE
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installCentOS4Package ${prefix} sudo
fi
#
# Log our finish
#
logMessage Script $0 finished

View File

@@ -63,7 +63,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -89,9 +88,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -112,9 +108,6 @@ done
#if [ $has_reiserfs -eq 1 ]; then
# installDebianPackage ${prefix} reiserfsprogs
#fi
#if [ $has_btrfs -eq 1 ]; then
# installDebianPackage ${prefix} btrfs-tools
#fi
#

View File

@@ -26,6 +26,12 @@ fi
logMessage Script $0 starting
#
# DNS is probably required to run "yum update".
#
cp /etc/resolv.conf ${prefix}/etc
#
# Update yum
#

View File

@@ -73,19 +73,6 @@ E_O_STATIC
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0

View File

@@ -0,0 +1,58 @@
#!/bin/sh
#
# Copy files from a 'skel' directory, if present, into the
# new images
#
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
#
# Copy "required" files from our host.
#
# NONE DONE
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installCentOS4Package ${prefix} sudo
fi
#
# Log our finish
#
logMessage Script $0 finished

View File

@@ -64,7 +64,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -90,9 +89,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -113,9 +109,6 @@ done
#if [ $has_reiserfs -eq 1 ]; then
# installDebianPackage ${prefix} reiserfsprogs
#fi
#if [ $has_btrfs -eq 1 ]; then
# installDebianPackage ${prefix} btrfs-tools
#fi
#

View File

@@ -85,7 +85,7 @@ installDebianPackage ()
#
# Use policy-rc to stop any daemons from starting.
#
printf '#!/bin/sh\nexit 101\n' > ${prefix}/usr/sbin/policy-rc.d
printf '#!/bin/bash\nexit 101\n' > ${prefix}/usr/sbin/policy-rc.d
chmod +x ${prefix}/usr/sbin/policy-rc.d
#
@@ -98,7 +98,9 @@ installDebianPackage ()
#
# Install the packages
#
mount -t devpts devpts ${prefix}/dev/pts
DEBIAN_FRONTEND=noninteractive chroot ${prefix} /usr/bin/apt-get --yes --force-yes install "$@"
umount ${prefix}/dev/pts
#
# Remove the policy-rc.d script.
@@ -224,18 +226,18 @@ installCentOS4Package ()
#
installPackage ()
{
prefix=$1
package=$2
prefix=$1
package=$2
if [ -x ${prefix}/usr/bin/apt-get ] ; then
installDebianPackage "$@"
if [ -x ${prefix}/usr/bin/apt-get ] ; then
installDebianPackage "$@"
elif [ -x ${prefix}/usr/bin/yum ] ; then
installCentOS4Package "$@"
elif [ -x ${prefix}/usr/bin/yum ] ; then
installCentOS4Package "$@"
else
logMessage "Unable to install package ${package}; no package manager found"
fi
else
logMessage "Unable to install package ${package}; no package manager found"
fi
}

View File

@@ -28,19 +28,36 @@ fi
logMessage Script $0 starting
#
# You will probably need DNS to run "apt-get update"
#
cp /etc/resolv.conf ${prefix}/etc
#
# Attempt to auto-magically detect the use of a Proxy for apt-get, and
# replicate that setup in our new guest via apt-config dump and save
# the setting to the proxy guess file.
# replicate that setup in our new guest.
#
logMessage The use of a proxy detected.
apt-config dump | grep -i Acquire::HTTP::Proxy \
> ${prefix}/etc/apt/apt.conf.d/proxy-guess
#
# Process any of the present apt-conf setup lines.
#
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 [ -e $i ] ; then
#
# Save the matching line(s) to the proxy guess file.
#
logMessage The use of a proxy detected.
grep -i HTTP::Proxy $i >> ${prefix}/etc/apt/apt.conf.d/proxy-guess
fi
done
#
# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
#
cat <<E_O_APT > ${prefix}/etc/apt/sources.list
#
# /etc/apt/sources.list

View File

@@ -112,20 +112,6 @@ E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -27,47 +27,37 @@ fi
#
logMessage Script $0 starting
#
# Determine the FQDN and Hostname
#
GUEST_FQDN=${hostname}
GUEST_HOSTNAME=`echo $GUEST_FQDN | awk -F'.' '{print $1}'`
#
# Setup the mailname + hostname files.
#
echo $GUEST_HOSTNAME > ${prefix}/etc/hostname
echo $GUEST_FQDN > ${prefix}/etc/mailname
echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname
echo ${hostname} > ${prefix}/etc/mailname
#
# Fixup the /etc/hosts file upon the new image for
# machines with static IPs
#
if [ -z "${copyhosts}" ]; then
#
# Copy localhost
#
cat > ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
EOF
#
# Make sure our hostname and FQDN is resolvable
#
if [ -z "${dhcp}" ]; then
#
# If dhcp is diabled, FQDN should resolve to our IP
#
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
if [ -z "${dhcp}" ]; then
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts
echo " " >> ${prefix}/etc/hosts
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
else
#
# Stub /etc/hosts for DHCP clients.
#
cat >> ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@@ -79,25 +69,7 @@ ff02::3 ip6-allhosts
EOF
else
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
if [ -z "${dhcp}" ]; then
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
fi
@@ -106,15 +78,22 @@ fi
#
if [ -z "${dhcp}" ]; then
if ( grep $GUEST_FQDN /etc/hosts > /dev/null ) ; then
if ( grep ${hostname} /etc/hosts > /dev/null ) ; then
logMessage Host already has IP address for the host $GUEST_FQDN.
logMessage Host already has IP address for the host ${hostname}.
else
#
# Short host name.
#
name=`echo ${hostname} | awk -F. '{print $1}'`
if [ -z "${nohosts}" ]; then
logMessage Adding $GUEST_FQDN and $GUEST_HOSTNAME to /etc/hosts on the host
echo "${ip1} $GUEST_FQDN $GUEST_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
@@ -122,12 +101,12 @@ if [ -z "${dhcp}" ]; 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 -s HUP `cat /var/run/dnsmasq.pid`
logMessage Allowing DNSMasq to restart.
kill -s HUP `cat /var/run/dnsmasq.pid`
fi
fi
fi

View File

@@ -30,6 +30,28 @@ logMessage Script $0 starting
cp /etc/timezone ${prefix}/etc
cp /etc/localtime ${prefix}/etc
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installDebianPackage ${prefix} sudo
fi
#
# Log our finish

View File

@@ -1,17 +1,18 @@
#!/bin/sh
#
# This script installs OpenSSH Server on the newly created guest.
# This script installs OpenSSH upon the new system.
#
# It does this by generating the keys within the host, since guests
# do not have the necessary /dev/random and /dev/urandom to generate
# their own keys before boot.
# It must make sure that the server is not running before it exits
# otherwise the temporary mounted directory will not be unmountable.
#
# Dmitry Nedospasov
# Steve
# --
# http://nedos.net/
# http://www.steve.org.uk/
prefix=$1
#
# Source our common functions
#
@@ -21,43 +22,21 @@ else
. ./hooks/common.sh
fi
#
# Log our start
#
logMessage Script $0 starting
#
# Since our guests doesn't have an RNG, generate the keys from the host
#
# First, create an ssh directory
#
mkdir -p ${prefix}/etc/ssh
#
# Second, Generate the Host RSA Key
#
if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host RSA"
else
logMessage "failed to generate Host RSA Key"
fi
#
# Third, Generate the Host DSA Key
#
if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host DSA"
else
logMessage "failed to generate Host DSA Key"
fi
#
# Install ssh
#
installDebianPackage ${prefix} openssh-server
installDebianPackage ${prefix} ssh
#
# Log our finish
# Log our finish
#
logMessage Script $0 finished

View File

@@ -60,7 +60,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -86,9 +85,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -109,9 +105,6 @@ fi
if [ $has_reiserfs -eq 1 ]; then
installDebianPackage ${prefix} reiserfsprogs
fi
if [ $has_btrfs -eq 1 ]; then
installDebianPackage ${prefix} btrfs-tools
fi
#

View File

@@ -29,10 +29,23 @@ logMessage Script $0 starting
#
# Disable the startup scripts from all runlevels.
#
chroot ${prefix} /usr/sbin/update-rc.d -f hwclock.sh remove
if [ -x ${prefix}/etc/init.d/hwclock.sh ]; then
chmod -x ${prefix}/etc/init.d/hwclock.sh
else
logMessage "/etc/init.d/hwclock.sh not found. skipping."
fi
if [ -x ${prefix}/etc/init.d/hwclockfirst.sh ]; then
chmod -x ${prefix}/etc/init.d/hwclockfirst.sh
else
logMessage "/etc/init.d/hwclockfirst.sh not found. skipping."
fi
#
# Log our finish
#
logMessage Script $0 finished.
logMessage Script $0 finished.

View File

@@ -28,13 +28,33 @@ logMessage Script $0 starting
#
# Attempt to auto-magically detect the use of a Proxy for apt-get, and
# replicate that setup in our new guest via apt-config dump and save
# the setting to the proxy guess file.
# You'll probably need DNS to run "apt-get update".
#
logMessage The use of a proxy detected.
apt-config dump | grep -i Acquire::HTTP::Proxy \
> ${prefix}/etc/apt/apt.conf.d/proxy-guess
cp /etc/resolv.conf ${prefix}/etc
#
# Attempt to auto-magically detect the use of a Proxy for apt-get, and
# replicate that setup in our new guest.
#
#
# Process any of the present apt-conf setup lines.
#
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 [ -e $i ] ; then
#
# Save the matching line(s) to the proxy guess file.
#
logMessage The use of a proxy detected.
grep -i HTTP::Proxy $i >> ${prefix}/etc/apt/apt.conf.d/proxy-guess
fi
done
#
@@ -59,7 +79,7 @@ E_O_APT
# If the host system has security support then enable that here, too,
# except if we're installing Debian Unstable.
#
if ( test "${dist}" "!=" "sid" && test "${dist}" "!=" "unstable" && \
if ( test "${dist}" '!=' 'sid' && test "${dist}" '!=' 'unstable' && \
test -e /etc/apt/sources.list && \
grep ^deb.*security -r /etc/apt/sources.list /etc/apt/sources.list.d >/dev/null 2>/dev/null ) ; then

View File

@@ -132,20 +132,6 @@ E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -27,47 +27,42 @@ fi
#
logMessage Script $0 starting
#
# Determine the FQDN and Hostname
#
GUEST_FQDN=${hostname}
GUEST_HOSTNAME=`echo $GUEST_FQDN | awk -F'.' '{print $1}'`
#
# Setup the mailname + hostname files.
#
echo $GUEST_HOSTNAME > ${prefix}/etc/hostname
echo $GUEST_FQDN > ${prefix}/etc/mailname
echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname
echo ${hostname} > ${prefix}/etc/mailname
#
# Fixup the /etc/hosts file upon the new image for
# machines with static IPs
#
if [ -z "${copyhosts}" ]; then
#
# Copy localhost
#
cat > ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
EOF
#
# Make sure our hostname and FQDN is resolvable
#
if [ -z "${dhcp}" ]; then
#
# If dhcp is diabled, FQDN should resolve to our IP
#
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
if [ -z "${dhcp}" ]; then
# Non-IPv6 stuff.
# TODO: Think of a better way of doing this, this may have a lot of trash
# depending on the dom0 (i.e. 127.0.0.1 dom0.example.com)
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
# echo "127.0.0.1 localhost" >> ${prefix}/etc/hosts
echo "127.0.1.1 $(echo ${hostname} | awk -F '.' '{ print $1 }')" >> ${prefix}/etc/hosts
echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts
echo " " >> ${prefix}/etc/hosts
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
else
#
# Stub /etc/hosts for DHCP clients.
#
cat >> ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
127.0.1.1 $(echo ${hostname} | awk -F '.' '{ print $1 }') ${hostname}
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@@ -79,25 +74,7 @@ ff02::3 ip6-allhosts
EOF
else
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
if [ -z "${dhcp}" ]; then
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
fi
@@ -106,15 +83,21 @@ fi
#
if [ -z "${dhcp}" ]; then
if ( grep $GUEST_FQDN /etc/hosts > /dev/null ) ; then
if ( grep ${hostname} /etc/hosts > /dev/null ) ; then
logMessage Host already has IP address for the host $GUEST_FQDN.
logMessage Host already has IP address for the host ${hostname}.
else
#
# Short host name.
#
name=`echo ${hostname} | awk -F. '{print $1}'`
if [ -z "${nohosts}" ]; then
logMessage Adding $GUEST_FQDN and $GUEST_HOSTNAME to /etc/hosts on the host
echo "${ip1} $GUEST_FQDN $GUEST_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

View File

@@ -33,8 +33,8 @@ MAKEDEV=''
MAKEDEV_PATHS="/sbin/MAKEDEV /dev/MAKEDEV"
for MAKEDEV_PATH in ${MAKEDEV_PATHS}; do
if [ -x "${prefix}${MAKEDEV_PATH}" ]; then
MAKEDEV="${prefix}${MAKEDEV_PATH}"
break
MAKEDEV="${prefix}${MAKEDEV_PATH}"
break
fi
done

View File

@@ -31,6 +31,29 @@ cp /etc/timezone ${prefix}/etc
cp /etc/localtime ${prefix}/etc
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installDebianPackage ${prefix} sudo
fi
#
# Log our finish
#

View File

@@ -1,17 +1,18 @@
#!/bin/sh
#
# This script installs OpenSSH Server on the newly created guest.
# This script installs OpenSSH upon the new system.
#
# It does this by generating the keys within the host, since guests
# do not have the necessary /dev/random and /dev/urandom to generate
# their own keys before boot.
# It must make sure that the server is not running before it exits
# otherwise the temporary mounted directory will not be unmountable.
#
# Dmitry Nedospasov
# Steve
# --
# http://nedos.net/
# http://www.steve.org.uk/
prefix=$1
#
# Source our common functions
#
@@ -21,43 +22,20 @@ else
. ./hooks/common.sh
fi
#
# Log our start
#
logMessage Script $0 starting
#
# Since our guests doesn't have an RNG, generate the keys from the host
#
# First, create an ssh directory
#
mkdir -p ${prefix}/etc/ssh
#
# Second, Generate the Host RSA Key
#
if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host RSA"
else
logMessage "failed to generate Host RSA Key"
fi
#
# Third, Generate the Host DSA Key
#
if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host DSA"
else
logMessage "failed to generate Host DSA Key"
fi
#
# Install ssh
#
installDebianPackage ${prefix} openssh-server
#
# Log our finish
# Log our finish
#
logMessage Script $0 finished

View File

@@ -33,25 +33,25 @@ logMessage Script $0 starting
#
if [ "${arch}" = "i386" ]; then
XEN_ARCH="686"
XEN_ARCH="686"
elif [ "${arch}" = "amd64" ]; then
XEN_ARCH="amd64"
XEN_ARCH="amd64"
elif [ -z "${arch}" ]; then
UNAME_ARCH=`uname -m`
if [ "${UNAME_ARCH}" = "i686" ]; then
XEN_ARCH="686"
elif [ "${UNAME_ARCH}" = "x86_64" ]; then
XEN_ARCH="amd64"
else
logMessage Unknown kernel architecture ${UNAME_ARCH}.
logMessage Please report this as bug to xen-tools-dev@xen-tools.org.
logMessage Script $0 failed
exit 1
fi
UNAME_ARCH=`uname -m`
if [ "${UNAME_ARCH}" = "i686" ]; then
XEN_ARCH="686"
elif [ "${UNAME_ARCH}" = "x86_64" ]; then
XEN_ARCH="amd64"
else
logMessage Unknown kernel architecture ${UNAME_ARCH}.
logMessage Please report this as bug to xen-tools-dev@xen-tools.org.
logMessage Script $0 failed
exit 1
fi
else
logMessage Unknown kernel architecture ${arch}
logMessage Script $0 failed
exit 1
logMessage Unknown kernel architecture ${arch}
logMessage Script $0 failed
exit 1
fi
#
@@ -68,19 +68,19 @@ if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_XEN_PKG > /dev/null 2>&1; th
installDebianPackage ${prefix} $KERNEL_XEN_PKG
else
logMessage Package $KERNEL_XEN_PKG is not available
logMessage Attempting to install the $KERNEL_PKG kernel image
logMessage WARNING: This kernel may not have pvops
if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_PKG > /dev/null 2>&1; then
logMessage Package $KERNEL_PKG is available - installing
installDebianPackage ${prefix} initramfs-tools
installDebianPackage ${prefix} $KERNEL_PKG
else
logMessage Package $KERNEL_PKG is not available
logMessage pygrub set, but kernel could not be installed
logMessage Script $0 failed
exit 1
fi
logMessage Package $KERNEL_XEN_PKG is not available
logMessage Attempting to install the $KERNEL_PKG kernel image
logMessage WARNING: This kernel may not have pvops
if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_PKG > /dev/null 2>&1; then
logMessage Package $KERNEL_PKG is available - installing
installDebianPackage ${prefix} initramfs-tools
installDebianPackage ${prefix} $KERNEL_PKG
else
logMessage Package $KERNEL_PKG is not available
logMessage pygrub set, but kernel could not be installed
logMessage Script $0 failed
exit 1
fi
fi
DOMU_KERNEL=$(basename $(ls -1 ${prefix}/boot/vmlinuz* | tail -n 1))
@@ -93,10 +93,10 @@ DOMU_ISSUE=$(sed -re "s/ *\\\.*//g" -e1q < ${prefix}/etc/issue)
#
if [ -f ${prefix}/boot/$DOMU_RAMDISK ]; then
logMessage initrd exists, skipping generation
logMessage initrd exists, skipping generation
else
logMessage initrd missing, generating
chroot ${prefix} update-initramfs -c -k $KERNEL_REV
logMessage initrd missing, generating
chroot ${prefix} update-initramfs -c -k $KERNEL_REV
fi
#

View File

@@ -59,7 +59,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -85,9 +84,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -108,9 +104,6 @@ fi
if [ $has_reiserfs -eq 1 ]; then
installDebianPackage ${prefix} reiserfsprogs
fi
if [ $has_btrfs -eq 1 ]; then
installDebianPackage ${prefix} btrfs-tools
fi
#

View File

@@ -37,10 +37,10 @@ fi
#
installDebianPackage ${prefix} locales
installDebianPackage ${prefix} util-linux-locales
chroot ${prefix} /usr/sbin/update-locale LANG=C
#
# Log our finish
#
logMessage Script $0 finished.
logMessage Script $0 finished.

View File

@@ -28,19 +28,38 @@ fi
logMessage Script $0 starting
#
# You will probably need DNS to run "apt-get update"
#
cp /etc/resolv.conf ${prefix}/etc
#
# Attempt to auto-magically detect the use of a Proxy for apt-get, and
# replicate that setup in our new guest via apt-config dump and save
# the setting to the proxy guess file.
# replicate that setup in our new guest.
#
logMessage The use of a proxy detected.
apt-config dump | grep -i Acquire::HTTP::Proxy \
> ${prefix}/etc/apt/apt.conf.d/proxy-guess
#
# 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
#
# If the file exists. (Need this in case the literal glob fails.)
#
if [ -e $i ] ; then
#
# Save the matching line(s) to the proxy guess file.
#
logMessage The use of a proxy detected.
grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
fi
done
#
# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
#
cat <<E_O_APT > ${prefix}/etc/apt/sources.list
#
# /etc/apt/sources.list

View File

@@ -121,20 +121,6 @@ E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -27,47 +27,37 @@ fi
#
logMessage Script $0 starting
#
# Determine the FQDN and Hostname
#
GUEST_FQDN=${hostname}
GUEST_HOSTNAME=`echo $GUEST_FQDN | awk -F'.' '{print $1}'`
#
# Setup the mailname + hostname files.
#
echo $GUEST_HOSTNAME > ${prefix}/etc/hostname
echo $GUEST_FQDN > ${prefix}/etc/mailname
echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname
echo ${hostname} > ${prefix}/etc/mailname
#
# Fixup the /etc/hosts file upon the new image for
# machines with static IPs
#
if [ -z "${copyhosts}" ]; then
#
# Copy localhost
#
cat > ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
EOF
#
# Make sure our hostname and FQDN is resolvable
#
if [ -z "${dhcp}" ]; then
#
# If dhcp is diabled, FQDN should resolve to our IP
#
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
if [ -z "${dhcp}" ]; then
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts
echo " " >> ${prefix}/etc/hosts
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
else
#
# Stub /etc/hosts for DHCP clients.
#
cat >> ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@@ -79,25 +69,7 @@ ff02::3 ip6-allhosts
EOF
else
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
if [ -z "${dhcp}" ]; then
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
fi
@@ -106,15 +78,20 @@ fi
#
if [ -z "${dhcp}" ]; then
if ( grep $GUEST_FQDN /etc/hosts > /dev/null ) ; then
if ( grep ${hostname} /etc/hosts > /dev/null ) ; then
logMessage Host already has IP address for the host $GUEST_FQDN.
logMessage Host already has IP address for the host ${hostname}.
else
#
# Short host name.
#
name=`echo ${hostname} | awk -F. '{print $1}'`
if [ -z "${nohosts}" ]; then
logMessage Adding $GUEST_FQDN and $GUEST_HOSTNAME to /etc/hosts on the host
echo "${ip1} $GUEST_FQDN $GUEST_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

View File

@@ -30,6 +30,28 @@ logMessage Script $0 starting
cp /etc/timezone ${prefix}/etc
cp /etc/localtime ${prefix}/etc
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installDebianPackage ${prefix} sudo
fi
#
# Log our finish

View File

@@ -1,17 +1,18 @@
#!/bin/sh
#
# This script installs OpenSSH Server on the newly created guest.
# This script installs OpenSSH upon the new system.
#
# It does this by generating the keys within the host, since guests
# do not have the necessary /dev/random and /dev/urandom to generate
# their own keys before boot.
# It must make sure that the server is not running before it exits
# otherwise the temporary mounted directory will not be unmountable.
#
# Dmitry Nedospasov
# Steve
# --
# http://nedos.net/
# http://www.steve.org.uk/
prefix=$1
#
# Source our common functions
#
@@ -21,43 +22,21 @@ else
. ./hooks/common.sh
fi
#
# Log our start
#
logMessage Script $0 starting
#
# Since our guests doesn't have an RNG, generate the keys from the host
#
# First, create an ssh directory
#
mkdir -p ${prefix}/etc/ssh
#
# Second, Generate the Host RSA Key
#
if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host RSA"
else
logMessage "failed to generate Host RSA Key"
fi
#
# Third, Generate the Host DSA Key
#
if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host DSA"
else
logMessage "failed to generate Host DSA Key"
fi
#
# Install ssh
#
installDebianPackage ${prefix} openssh-server
installDebianPackage ${prefix} ssh
#
# Log our finish
# Log our finish
#
logMessage Script $0 finished

View File

@@ -43,19 +43,19 @@ if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_XEN_PKG > /dev/null 2>&1; th
installDebianPackage ${prefix} $KERNEL_XEN_PKG
else
logMessage Package $KERNEL_XEN_PKG is not available
logMessage Attempting to install the $KERNEL_PKG kernel image
logMessage WARNING: This kernel may not have pvops
if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_PKG > /dev/null 2>&1; then
logMessage Package $KERNEL_PKG is available - installing
installDebianPackage ${prefix} initramfs-tools
installDebianPackage ${prefix} $KERNEL_PKG
else
logMessage Package $KERNEL_PKG is not available
logMessage pygrub set, but kernel could not be installed
logMessage Script $0 failed
exit 1
fi
logMessage Package $KERNEL_XEN_PKG is not available
logMessage Attempting to install the $KERNEL_PKG kernel image
logMessage WARNING: This kernel may not have pvops
if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_PKG > /dev/null 2>&1; then
logMessage Package $KERNEL_PKG is available - installing
installDebianPackage ${prefix} initramfs-tools
installDebianPackage ${prefix} $KERNEL_PKG
else
logMessage Package $KERNEL_PKG is not available
logMessage pygrub set, but kernel could not be installed
logMessage Script $0 failed
exit 1
fi
fi
DOMU_KERNEL=$(basename $(ls -1 ${prefix}/boot/vmlinuz* | tail -n 1))
@@ -68,10 +68,10 @@ DOMU_ISSUE=$(sed -re "s/ *\\\.*//g" -e1q < ${prefix}/etc/issue)
#
if [ -f ${prefix}/boot/$DOMU_RAMDISK ]; then
logMessage initrd exists, skipping generation
logMessage initrd exists, skipping generation
else
logMessage initrd missing, generating
chroot ${prefix} update-initramfs -c -k $KERNEL_REV
logMessage initrd missing, generating
chroot ${prefix} update-initramfs -c -k $KERNEL_REV
fi
#

View File

@@ -60,7 +60,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -86,9 +85,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -109,9 +105,6 @@ fi
if [ $has_reiserfs -eq 1 ]; then
installDebianPackage ${prefix} reiserfsprogs
fi
if [ $has_btrfs -eq 1 ]; then
installDebianPackage ${prefix} btrfs-tools
fi
#

View File

@@ -26,6 +26,13 @@ fi
logMessage Script $0 starting
#
# DNS is probably required to run "yum update".
#
cp /etc/resolv.conf ${prefix}/etc
#
# Update yum
#

View File

@@ -73,19 +73,6 @@ E_O_STATIC
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0

View File

@@ -0,0 +1,58 @@
#!/bin/sh
#
# Copy files from a 'skel' directory, if present, into the
# new images
#
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
#
# Copy "required" files from our host.
#
# NONE DONE
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installCentOS4Package ${prefix} sudo
fi
#
# Log our finish
#
logMessage Script $0 finished

View File

@@ -63,7 +63,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -89,9 +88,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -112,9 +108,6 @@ done
#if [ $has_reiserfs -eq 1 ]; then
# installDebianPackage ${prefix} reiserfsprogs
#fi
#if [ $has_btrfs -eq 1 ]; then
# installDebianPackage ${prefix} btrfs-tools
#fi
#

View File

@@ -96,20 +96,6 @@ E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

59
hooks/gentoo/60-copy-host-files Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/sh
#
# Copy files from a 'skel' directory, if present, into the
# new images
#
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
#
# Copy "required" files from our host.
#
cp /etc/resolv.conf ${prefix}/etc
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/resolv.conf ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installDebianPackage ${prefix} sudo
fi
#
# Log our finish
#
logMessage Script $0 finished

View File

@@ -60,7 +60,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -86,9 +85,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -109,9 +105,6 @@ done
#if [ $has_reiserfs -eq 1 ]; then
# installDebianPackage ${prefix} reiserfsprogs
#fi
#if [ $has_btrfs -eq 1 ]; then
# installDebianPackage ${prefix} btrfs-tools
#fi
#

View File

@@ -28,19 +28,38 @@ fi
logMessage Script $0 starting
#
# You will probably need DNS to run "apt-get update"
#
cp /etc/resolv.conf ${prefix}/etc
#
# Attempt to auto-magically detect the use of a Proxy for apt-get, and
# replicate that setup in our new guest via apt-config dump and save
# the setting to the proxy guess file.
# replicate that setup in our new guest.
#
logMessage The use of a proxy detected.
apt-config dump | grep -i Acquire::HTTP::Proxy \
> ${prefix}/etc/apt/apt.conf.d/proxy-guess
#
# 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
#
# If the file exists. (Need this in case the literal glob fails.)
#
if [ -e $i ] ; then
#
# Save the matching line(s) to the proxy guess file.
#
logMessage The use of a proxy detected.
grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
fi
done
#
# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
#
cat <<E_O_APT > ${prefix}/etc/apt/sources.list
#
# /etc/apt/sources.list

View File

@@ -27,12 +27,10 @@ logMessage Script $0 starting
#
# Remove the links for upstart
#
rm -f ${prefix}/etc/event.d/tty[!1]
[ -f ${prefix}/etc/event.d/tty1 ] && {
sed -i -e s/tty1/hvc0/ ${prefix}/etc/event.d/tty1
mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/hvc0
}
[ -f ${prefix}/etc/inittab ] && sed -i -e 's/^\([2-6].*:respawn*\)/#\1/' -e 's/^T/#\t/' -e 's/tty1$/hvc0/' ${prefix}/etc/inittab
rm ${prefix}/etc/event.d/tty[!1]
sed -i -e s/tty1/hvc0/ ${prefix}/etc/event.d/tty1
mv ${prefix}/etc/event.d/tty1 ${prefix}/etc/event.d/hvc0
[ -f ${prefix}/etc/inittab ] && sed -i -e s/tty1/hvc0/ ${prefix}/etc/inittab
#
# Are we using an alternative serial device?

View File

@@ -121,20 +121,6 @@ E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -27,47 +27,37 @@ fi
#
logMessage Script $0 starting
#
# Determine the FQDN and Hostname
#
GUEST_FQDN=${hostname}
GUEST_HOSTNAME=`echo $GUEST_FQDN | awk -F'.' '{print $1}'`
#
# Setup the mailname + hostname files.
#
echo $GUEST_HOSTNAME > ${prefix}/etc/hostname
echo $GUEST_FQDN > ${prefix}/etc/mailname
echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname
echo ${hostname} > ${prefix}/etc/mailname
#
# Fixup the /etc/hosts file upon the new image for
# machines with static IPs
#
if [ -z "${copyhosts}" ]; then
#
# Copy localhost
#
cat > ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
EOF
#
# Make sure our hostname and FQDN is resolvable
#
if [ -z "${dhcp}" ]; then
#
# If dhcp is diabled, FQDN should resolve to our IP
#
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
if [ -z "${dhcp}" ]; then
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts
echo " " >> ${prefix}/etc/hosts
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
else
#
# Stub /etc/hosts for DHCP clients.
#
cat >> ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@@ -79,25 +69,7 @@ ff02::3 ip6-allhosts
EOF
else
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
if [ -z "${dhcp}" ]; then
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
fi
@@ -106,15 +78,20 @@ fi
#
if [ -z "${dhcp}" ]; then
if ( grep $GUEST_FQDN /etc/hosts > /dev/null ) ; then
if ( grep ${hostname} /etc/hosts > /dev/null ) ; then
logMessage Host already has IP address for the host $GUEST_FQDN.
logMessage Host already has IP address for the host ${hostname}.
else
#
# Short host name.
#
name=`echo ${hostname} | awk -F. '{print $1}'`
if [ -z "${nohosts}" ]; then
logMessage Adding $GUEST_FQDN and $GUEST_HOSTNAME to /etc/hosts on the host
echo "${ip1} $GUEST_FQDN $GUEST_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

View File

@@ -30,6 +30,28 @@ logMessage Script $0 starting
cp /etc/timezone ${prefix}/etc
cp /etc/localtime ${prefix}/etc
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installDebianPackage ${prefix} sudo
fi
#
# Log our finish

View File

@@ -1,17 +1,18 @@
#!/bin/sh
#
# This script installs OpenSSH Server on the newly created guest.
# This script installs OpenSSH upon the new system.
#
# It does this by generating the keys within the host, since guests
# do not have the necessary /dev/random and /dev/urandom to generate
# their own keys before boot.
# It must make sure that the server is not running before it exits
# otherwise the temporary mounted directory will not be unmountable.
#
# Dmitry Nedospasov
# Steve
# --
# http://nedos.net/
# http://www.steve.org.uk/
prefix=$1
#
# Source our common functions
#
@@ -21,43 +22,21 @@ else
. ./hooks/common.sh
fi
#
# Log our start
#
logMessage Script $0 starting
#
# Since our guests doesn't have an RNG, generate the keys from the host
#
# First, create an ssh directory
#
mkdir -p ${prefix}/etc/ssh
#
# Second, Generate the Host RSA Key
#
if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host RSA"
else
logMessage "failed to generate Host RSA Key"
fi
#
# Third, Generate the Host DSA Key
#
if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host DSA"
else
logMessage "failed to generate Host DSA Key"
fi
#
# Install ssh
#
installDebianPackage ${prefix} openssh-server
installDebianPackage ${prefix} ssh
#
# Log our finish
# Log our finish
#
logMessage Script $0 finished

View File

@@ -38,14 +38,14 @@ KERNEL_PKG="linux-image-server"
logMessage Attempting to install the $KERNEL_PKG kernel image
logMessage WARNING: This kernel may not have pvops
if chroot ${prefix} /usr/bin/apt-cache show $KERNEL_PKG > /dev/null 2>&1; then
logMessage Package $KERNEL_PKG is available - installing
logMessage Package $KERNEL_PKG is available - installing
installDebianPackage ${prefix} initramfs-tools
installDebianPackage ${prefix} $KERNEL_PKG
else
logMessage Package $KERNEL_PKG is not available
logMessage pygrub set, but kernel could not be installed
logMessage Script $0 failed
exit 1
logMessage Package $KERNEL_PKG is not available
logMessage pygrub set, but kernel could not be installed
logMessage Script $0 failed
exit 1
fi
DOMU_KERNEL=$(basename $(ls -1 ${prefix}/boot/vmlinuz* | tail -n 1))
@@ -58,10 +58,10 @@ DOMU_ISSUE=$(sed -re "s/ *\\\.*//g" -e1q < ${prefix}/etc/issue)
#
if [ -f ${prefix}/boot/$DOMU_RAMDISK ]; then
logMessage initrd exists, skipping generation
logMessage initrd exists, skipping generation
else
logMessage initrd missing, generating
chroot ${prefix} update-initramfs -c -k $KERNEL_REV
logMessage initrd missing, generating
chroot ${prefix} update-initramfs -c -k $KERNEL_REV
fi
#

View File

@@ -60,7 +60,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -86,9 +85,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -109,9 +105,6 @@ fi
if [ $has_reiserfs -eq 1 ]; then
installDebianPackage ${prefix} reiserfsprogs
fi
if [ $has_btrfs -eq 1 ]; then
installDebianPackage ${prefix} btrfs-tools
fi
#

View File

@@ -28,19 +28,38 @@ fi
logMessage Script $0 starting
#
# You will probably need DNS to run "apt-get update"
#
cp /etc/resolv.conf ${prefix}/etc
#
# Attempt to auto-magically detect the use of a Proxy for apt-get, and
# replicate that setup in our new guest via apt-config dump and save
# the setting to the proxy guess file.
# replicate that setup in our new guest.
#
logMessage The use of a proxy detected.
apt-config dump | grep -i Acquire::HTTP::Proxy \
> ${prefix}/etc/apt/apt.conf.d/proxy-guess
#
# 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
#
# If the file exists. (Need this in case the literal glob fails.)
#
if [ -e $i ] ; then
#
# Save the matching line(s) to the proxy guess file.
#
logMessage The use of a proxy detected.
grep -v '^//' $i | grep -i HTTP::Proxy >>${prefix}/etc/apt/apt.conf.d/proxy-guess
fi
done
#
# Setup the sources.list file for new installations of Ubuntu GNU/Linux.
#
cat <<E_O_APT > ${prefix}/etc/apt/sources.list
#
# /etc/apt/sources.list

View File

@@ -27,12 +27,10 @@ logMessage Script $0 starting
#
# Remove the links for upstart
#
rm -f ${prefix}/etc/init/tty[!1].conf
[ -f ${prefix}/etc/init/tty1.conf ] && {
sed -i -e s/tty1/hvc0/ ${prefix}/etc/init/tty1.conf
mv ${prefix}/etc/init/tty1.conf ${prefix}/etc/init/hvc0.conf
}
[ -f ${prefix}/etc/inittab ] && sed -i -e 's/^\([2-6].*:respawn*\)/#\1/' -e 's/^T/#\t/' -e 's/tty1$/hvc0/' ${prefix}/etc/inittab
rm ${prefix}/etc/init/tty[!1].conf
sed -i -e s/tty1/hvc0/ ${prefix}/etc/init/tty1.conf
mv ${prefix}/etc/init/tty1.conf ${prefix}/etc/init/hvc0.conf
#
# Are we using an alternative serial device?

View File

@@ -121,20 +121,6 @@ E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
#
# Hooks are run chrooted, hence the resolv.conf is moved
# temporarily to /etc/resolv.conf.old. Use that file, it
# will be restored after hooks are run.
#
if [ '' != "$nameserver" ]; then
rm -f ${prefix}/etc/resolv.conf.old
for ns in $nameserver; do
echo "nameserver $ns" >>${prefix}/etc/resolv.conf.old
done
else
cp /etc/resolv.conf ${prefix}/etc/resolv.conf.old
fi
}

View File

@@ -27,47 +27,37 @@ fi
#
logMessage Script $0 starting
#
# Determine the FQDN and Hostname
#
GUEST_FQDN=${hostname}
GUEST_HOSTNAME=`echo $GUEST_FQDN | awk -F'.' '{print $1}'`
#
# Setup the mailname + hostname files.
#
echo $GUEST_HOSTNAME > ${prefix}/etc/hostname
echo $GUEST_FQDN > ${prefix}/etc/mailname
echo ${hostname} | sed 's/^\([^\.]*\)\..*/\1/' > ${prefix}/etc/hostname
echo ${hostname} > ${prefix}/etc/mailname
#
# Fixup the /etc/hosts file upon the new image for
# machines with static IPs
#
if [ -z "${copyhosts}" ]; then
#
# Copy localhost
#
cat > ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
EOF
#
# Make sure our hostname and FQDN is resolvable
#
if [ -z "${dhcp}" ]; then
#
# If dhcp is diabled, FQDN should resolve to our IP
#
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
if [ -z "${dhcp}" ]; then
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
echo "${ip1} ${hostname}" >> ${prefix}/etc/hosts
echo " " >> ${prefix}/etc/hosts
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
else
#
# Stub /etc/hosts for DHCP clients.
#
cat >> ${prefix}/etc/hosts <<EOF
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@@ -79,25 +69,7 @@ ff02::3 ip6-allhosts
EOF
else
# Non-IPv6 stuff.
grep -v '\(::\|IPv6\)' /etc/hosts > ${prefix}/etc/hosts
# New entry.
if [ -z "${dhcp}" ]; then
cat >> ${prefix}/etc/hosts <<EOF
${ip1} $GUEST_FQDN $GUEST_HOSTNAME
EOF
else
cat >> ${prefix}/etc/hosts <<EOF
127.0.1.1 $GUEST_FQDN $GUEST_HOSTNAME
EOF
fi
# IPv6 stuff.
grep '\(::\|IPv6\)' /etc/hosts >> ${prefix}/etc/hosts
fi
@@ -106,15 +78,20 @@ fi
#
if [ -z "${dhcp}" ]; then
if ( grep $GUEST_FQDN /etc/hosts > /dev/null ) ; then
if ( grep ${hostname} /etc/hosts > /dev/null ) ; then
logMessage Host already has IP address for the host $GUEST_FQDN.
logMessage Host already has IP address for the host ${hostname}.
else
#
# Short host name.
#
name=`echo ${hostname} | awk -F. '{print $1}'`
if [ -z "${nohosts}" ]; then
logMessage Adding $GUEST_FQDN and $GUEST_HOSTNAME to /etc/hosts on the host
echo "${ip1} $GUEST_FQDN $GUEST_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

View File

@@ -30,6 +30,28 @@ logMessage Script $0 starting
cp /etc/timezone ${prefix}/etc
cp /etc/localtime ${prefix}/etc
#
# If the host has sudo then copy the configuration file, and install
# the package
#
if [ -e /etc/sudoers ]; then
logMessage Installing SUDO too.
#
# Copy file and fixup permissions.
#
cp /etc/sudoers ${prefix}/etc
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Install sudo
#
installDebianPackage ${prefix} sudo
fi
#
# Log our finish

View File

@@ -1,17 +1,18 @@
#!/bin/sh
#
# This script installs OpenSSH Server on the newly created guest.
# This script installs OpenSSH upon the new system.
#
# It does this by generating the keys within the host, since guests
# do not have the necessary /dev/random and /dev/urandom to generate
# their own keys before boot.
# It must make sure that the server is not running before it exits
# otherwise the temporary mounted directory will not be unmountable.
#
# Dmitry Nedospasov
# Steve
# --
# http://nedos.net/
# http://www.steve.org.uk/
prefix=$1
#
# Source our common functions
#
@@ -21,43 +22,21 @@ else
. ./hooks/common.sh
fi
#
# Log our start
#
logMessage Script $0 starting
#
# Since our guests doesn't have an RNG, generate the keys from the host
#
# First, create an ssh directory
#
mkdir -p ${prefix}/etc/ssh
#
# Second, Generate the Host RSA Key
#
if ssh-keygen -t rsa -N "" -f ${prefix}/etc/ssh/ssh_host_rsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host RSA"
else
logMessage "failed to generate Host RSA Key"
fi
#
# Third, Generate the Host DSA Key
#
if ssh-keygen -t dsa -N "" -f ${prefix}/etc/ssh/ssh_host_dsa_key -C "root@${hostname}"; then
logMessage "successfully generetaged Host DSA"
else
logMessage "failed to generate Host DSA Key"
fi
#
# Install ssh
#
installDebianPackage ${prefix} openssh-server
installDebianPackage ${prefix} ssh
#
# Log our finish
# Log our finish
#
logMessage Script $0 finished

View File

@@ -60,7 +60,6 @@ logMessage "Root device is /dev/$device"
#
has_xfs=0
has_reiserfs=0
has_btrfs=0
cat <<E_O_FSTAB > ${prefix}/etc/fstab
# /etc/fstab: static file system information.
#
@@ -86,9 +85,6 @@ for part in `seq 1 ${NUMPARTITIONS}`; do
reiserfs)
has_reiserfs=1
;;
btrfs)
has_btrfs=1
;;
esac
if [ "${partdata2}" = "swap" ]; then
@@ -109,9 +105,6 @@ fi
if [ $has_reiserfs -eq 1 ]; then
installDebianPackage ${prefix} reiserfsprogs
fi
if [ $has_btrfs -eq 1 ]; then
installDebianPackage ${prefix} btrfs-tools
fi
#

View File

@@ -319,6 +319,10 @@ L<http://search.cpan.org/dist/Xen-Tools>
=back
=head1 ACKNOWLEDGEMENTS
=head1 COPYRIGHT & LICENSE
Copyright 2007 C.J. Adams-Collier, all rights reserved.

View File

@@ -149,7 +149,7 @@ sub _init_fh {
my $logFile =
File::Spec->catfile( $self->logpath(), $self->hostname() . '.log' );
system( qw(mkdir -p), $self->logpath() ) unless -d $self->logpath();
system( 'mkdir -p', $self->logpath() ) unless -d $self->logpath();
carp "Couldn't create log directory: $!" unless $? == 0;
@@ -199,6 +199,10 @@ L<http://search.cpan.org/dist/Xen-Tools>
=back
=head1 ACKNOWLEDGEMENTS
=head1 COPYRIGHT & LICENSE
Copyright 2007 C.J. Adams-Collier, all rights reserved.

View File

@@ -2,7 +2,7 @@
#
# /etc/bash_completion.d/xen-tools
#
# Completion functions for Bash.
# Completion functions for Bash.
#
# This file offers basic support for all the command line options, along with
# some specialist support to complete filesystem types, distribution targets,
@@ -55,8 +55,8 @@ _xen_create_image()
# Determine arguments dynamically. Avoids out-of-dateness.
opts=$(xen-create-image --help|grep -- --|awk '{print $1}' |grep -- -- | sort -u)
#
# Complete the initial part of the IP in the configuration file.
ip=`grep ^gateway /etc/xen-tools/xen-tools.conf 2>/dev/null | awk -F'= ' '{print $2}'`
@@ -78,127 +78,71 @@ _xen_create_image()
#
# EVMS container completion
#
#
evmscontainers=`evms_query containers 2>/dev/null`
case "$prev" in
--cache)
COMPREPLY=( $( compgen -W 'yes no' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--cachedir)
_filedir -d
return 0
;;
--config)
_filedir .conf
return 0
;;
--debootstrap-cmd)
_filedir
return 0
;;
--dir)
_filedir -d
return 0
;;
--dist)
COMPREPLY=( $( compgen -W '${dists}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--evms)
COMPREPLY=( $( compgen -W '${evmscontainers}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--fs)
COMPREPLY=( $( compgen -W 'ext2 ext3 ext4 xfs reiserfs btrfs' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--genpass)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--hash_method)
COMPREPLY=( $( compgen -W 'md5 sha256 sha512' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--hooks)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--image)
COMPREPLY=( $( compgen -W 'sparse full' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--image-dev)
_filedir
return 0
;;
--initrd)
_filedir
return 0
;;
--initrd)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-method)
COMPREPLY=( $( compgen -W 'copy debootstrap rinse rpmstrap tar' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-source)
_filedir
return 0
;;
--ip)
ip=`echo ${ip} | sed -e 's/[.][^.]*$/./'`
COMPREPLY=( $(compgen -W "${ip}" -- ${cur}) )
return 0
;;
--kernel)
_filedir
return 0
;;
--lvm)
COMPREPLY=( $( compgen -W '${vgs}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--modules)
_filedir -d
return 0
;;
--output)
_filedir -d
return 0
;;
--partitions)
partitions=$(for x in `/bin/ls -1 /etc/xen-tools/partitions.d/ 2>/dev/null | grep -v \/ 2>/dev/null`; do echo ${x} ; done )
COMPREPLY=( $( compgen -W '${partitions}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--role)
--cache)
COMPREPLY=( $( compgen -W 'yes no' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--config)
_filedir
return 0
;;
--dir)
_filedir -d
return 0
;;
--dist)
COMPREPLY=( $( compgen -W '${dists}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--evms)
COMPREPLY=( $( compgen -W '${evmscontainers}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--fs)
COMPREPLY=( $( compgen -W 'xfs ext3 reiserfs' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--hooks)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--image)
COMPREPLY=( $( compgen -W 'sparse full' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-method)
COMPREPLY=( $( compgen -W 'copy debootstrap rinse rpmstrap tar' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--ip)
ip=`echo ${ip} | sed -e 's/[.][^.]*$/./'`
COMPREPLY=( $(compgen -W "${ip}" -- ${cur}) )
return 0
;;
--lvm)
COMPREPLY=( $( compgen -W '${vgs}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--role)
roles=$(ls -1 /etc/xen-tools/role.d/ | xargs echo )
COMPREPLY=( $( compgen -W '${roles}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--roledir)
_filedir -d
return 0
;;
--swap-dev)
_filedir
return 0
;;
--template)
_filedir
return 0
;;
COMPREPLY=( $( compgen -W '${roles}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--partitions)
partitions=$(for x in `/bin/ls -1 /etc/xen-tools/partitions.d/ 2>/dev/null | grep -v \/ 2>/dev/null`; do echo ${x} ; done )
COMPREPLY=( $( compgen -W '${partitions}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
esac
if [[ ${cur} == -* ]] || [[ ${prev} == xen-create-image ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
@@ -223,14 +167,14 @@ _xen_create_nfs()
# Determine arguments dynamically. Avoids out-of-dateness.
opts=$(xen-create-nfs --help|grep -- --|awk '{print $1}' |grep -- -- | sort -u)
case "$prev" in
--template)
_filedir
return 0
;;
--template)
_filedir
return 0
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
@@ -243,7 +187,7 @@ complete -F _xen_create_nfs xen-create-nfs
#
# Completion for xen-delete-image
#
_xen_delete_image()
_xen_delete_image()
{
local cur prev opts vgs names
COMPREPLY=()
@@ -257,7 +201,7 @@ _xen_delete_image()
#
# EVMS container completion
#
#
evmscontainers=`evms_query containers 2>/dev/null`
#
@@ -269,22 +213,22 @@ _xen_delete_image()
case "${prev}" in
--dir)
_filedir -d
return 0
;;
--evms)
COMPREPLY=( $( compgen -W '${evmscontainers}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
_filedir -d
return 0
;;
--evms)
COMPREPLY=( $( compgen -W '${evmscontainers}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--hostname)
names=`_find_xen_images`
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
return 0
;;
--lvm)
COMPREPLY=( $( compgen -W '${vgs}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
return 0
;;
--lvm)
COMPREPLY=( $( compgen -W '${vgs}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
esac
if [[ ${cur} == -* ]]; then
@@ -305,7 +249,7 @@ complete -F _xen_delete_image xen-delete-image
#
# Completion for xen-update-image
#
_xen_update_image()
_xen_update_image()
{
local cur prev opts base names vgs
COMPREPLY=()
@@ -327,17 +271,17 @@ _xen_update_image()
case "${prev}" in
--dir)
_filedir -d
return 0
;;
--evms)
COMPREPLY=( $( compgen -W '${evmscontainers}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--lvm)
COMPREPLY=( $( compgen -W '${vgs}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
_filedir -d
return 0
;;
--evms)
COMPREPLY=( $( compgen -W '${evmscontainers}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--lvm)
COMPREPLY=( $( compgen -W '${vgs}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
esac
if [[ ${cur} == -* ]]; then
@@ -357,7 +301,7 @@ complete -F _xen_update_image xen-update-image
#
# Completion for xen-list-images
#
_xen_list_images()
_xen_list_images()
{
local cur prev opts vgs
COMPREPLY=()
@@ -389,19 +333,19 @@ _xt-create-xen-config()
# Determine arguments dynamically. Avoids out-of-dateness.
opts=$(xt-create-xen-config --help|grep -- --|awk '{print $1}'|grep -- -- | sort -u)
case "$prev" in
--output)
_filedir -d
return 0
;;
--template)
COMPREPLY=( $( compgen -f -- ${cur#*:} ) )
return 0
;;
--output)
_filedir -d
return 0
;;
--template)
COMPREPLY=( $( compgen -f -- ${cur#*:} ) )
return 0
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
@@ -424,25 +368,25 @@ _xt-customize-image()
# Determine arguments dynamically. Avoids out-of-dateness.
opts=$(xt-customize-image --help|grep -- --|awk '{print $1}'|grep -- -- | sort -u)
#
# Available distributions, from rpmstrap
#
if [ -d /usr/lib/rpmstrap/scripts ]; then
dists=`/bin/ls -1 /usr/lib/rpmstrap/scripts`
fi
case "$prev" in
--dist)
COMPREPLY=( $( compgen -W '${dists} sid sarge etch lenny' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--location)
_filedir -d
return 0
;;
--dist)
COMPREPLY=( $( compgen -W '${dists} sid sarge etch lenny' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--location)
_filedir -d
return 0
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
@@ -466,7 +410,7 @@ _xt-install-image()
# Determine arguments dynamically. Avoids out-of-dateness.
opts=$(xt-install-image --help|grep -- --|awk '{print $1}'|grep -- -- | sort -u)
#
# Available distributions, from rpmstrap
#
@@ -476,28 +420,28 @@ _xt-install-image()
case "$prev" in
--cache)
COMPREPLY=( $( compgen -W 'yes no' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--config)
_filedir
return 0
;;
--dist)
COMPREPLY=( $( compgen -W '${dists} sid sarge etch lenny' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-method)
COMPREPLY=( $( compgen -W 'copy debootstrap rinse rpmstrap tar' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--location)
_filedir -d
return 0
;;
--cache)
COMPREPLY=( $( compgen -W 'yes no' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--config)
_filedir
return 0
;;
--dist)
COMPREPLY=( $( compgen -W '${dists} sid sarge etch lenny' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--install-method)
COMPREPLY=( $( compgen -W 'copy debootstrap rinse rpmstrap tar' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--location)
_filedir -d
return 0
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0

186
roles/passwd Executable file
View File

@@ -0,0 +1,186 @@
#!/usr/bin/perl -w
=head1 NAME
passwd - xen-tools role-script to setup root password for new guests.
=head1 AUTHOR
Steve
--
http://www.steve.org.uk/
=cut
use strict;
use warnings;
use Digest::MD5;
use Expect;
#
# Get the arguments our role script was passed.
#
my( $prefix, $passwd ) = ( @ARGV );
#
# Make sure they are valid.
#
if ( ! -d $prefix )
{
print "Prefix not found: $prefix\n";
exit;
}
if ( ! length( $passwd ) )
{
print "Password missing.\n";
exit;
}
#
# Now make sure we have the module we require.
#
eval "use Expect;";
if ( $@ )
{
print "Expect.pm not found. Aborting.\n";
print "(For Debian systems run:\n\tapt-get install libexpect-perl\n";
exit;
}
#
# OK now we're good to go: Continue until it succeeds.
#
my $count = 0;
while( $count < 10 )
{
changePassword( $prefix, $passwd );
$count += 1;
}
print "Failed to setup root password\n";
print "-----------------------------\n";
#
# Don't look at this code.
#
# OK. Expect sometimes fails. It sucks.
#
# So how do we know if a password change operation fails? We take
# an MD5(/etc/passwd + /etc/shadow) and if they don't change we've
# failed.
#
# Upon success we will simply exit();
#
#
sub changePassword
{
my ( $prefix, $passwd ) = ( @_ );
#
# Find current checksum.
#
my $orig = checksum( $prefix );
#
# Create the expect object.
#
my $exp = Expect->spawn( "/usr/sbin/chroot",
$prefix,
"/usr/bin/passwd",
"root" )
or die "Cannot spawn the password under chroot: $!\n";
# prompt
unless ($exp->expect(5,"Enter new"))
{
print "Failed 1st prompt\n";
$exp->hard_close();
return;
}
# send + wait.
$exp->send( $passwd . "\n" );
sleep( 1 );
# confirm
unless ($exp->expect(5,"Retype new"))
{
print "Failed 2nd prompt\n";
$exp->hard_close();
return;
}
# send.
$exp->send( $passwd . "\n" );
# Closeup.
$exp->soft_close();
#
# Did it work?
#
my $updated = checksum( $prefix );
if ( $updated ne $orig )
{
print "Password setup correctly.\n";
exit;
}
else
{
print "Setting password failed.\n";
}
}
#
# Checksum /etc/passwd + /etc/shadow if they exist in the
# given chroot()
#
sub checksum
{
my( $prefix ) = ( @_ );
my $sum = '';
foreach my $file ( qw! /etc/passwd /etc/shadow ! )
{
if ( -e $prefix . "/" . $file )
{
#
# Open the file.
#
open(FILE, $prefix . "/" . $file)
or die "Can¡Çt open ¡Ç$prefix/$file¡Ç: $!";
binmode(FILE);
#
# Add the data
#
my $md5 = Digest::MD5->new;
while (<FILE>)
{
$md5->add($_);
}
close(FILE);
#
# Update the sum
#
$sum .= $md5->b64digest;
}
}
return $sum;
}

View File

@@ -1,44 +0,0 @@
#!/bin/sh
#
# This role helps to customize guest's /etc/resolv.conf
#
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
#
# WARNING :
#
# resolv.conf is backed up as resolv.conf.old during roles execution to
# permit the chrooted guest to be able to resolve during installation.
# Use resolv.conf.old name during hooks, it will be correctly renamed
# after hooks execution
#
#
# Create Guest's resolv.conf as resolv.conf.old (see WARNING before) :
#
cat <<RESOLV_CONF_EOF >${prefix}/etc/resolv.conf.old
nameserver 192.168.1.1
#search domain.tld
RESOLV_CONF_EOF
#
# Log our finish
#
logMessage Script $0 finished

View File

@@ -1,46 +0,0 @@
#!/bin/sh
#
# This role installs sudo with host sudoers file.
#
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 sudo package
#
installDebianPackage ${prefix} sudo
#
# WARNING :
#
# Copying this file means that root users in guest will KNOW who is
# root on host.
#
#
# Copy dom0's file to domU.
#
cp /etc/sudoers ${prefix}/etc/
chown root:root ${prefix}/etc/sudoers
chmod 440 ${prefix}/etc/sudoers
#
# Log our finish
#
logMessage Script $0 finished

2
t/.gitignore vendored
View File

@@ -1,2 +0,0 @@
# Automatically generated by modules.sh
/modules.t

View File

@@ -6,8 +6,11 @@ verbose:
@cd ..; prove --shuffle --verbose t/
modules: modules.sh
modules: .PHONY
./modules.sh > modules.t
.PHONY:
true
clean:
-rm *~

View File

@@ -45,8 +45,9 @@ foreach my $key ( sort keys %OPTIONS )
}
}
next if ( $key =~ /^mirror_/ );
next if ( $key =~ /_options$/ );
next if ( $key =~ /mirror_/i );
next if ( $key =~ /_options/i );
next if ( $key =~ /(serial_device|disk_device)/i );
is( $found, 1 , " Found documentation for '$key'" );
}

View File

@@ -59,7 +59,7 @@ sub testFile
#
# Test we discovered some documented options.
#
ok( $#documented > 1, "We found some options documented in $file." );
ok( $#documented > 1, "We found some options documented." );
@@ -105,11 +105,11 @@ sub testFile
#print " - strip comments : $o ";
#
# Remove "" or '' around it.
# Remove "" from around it.
#
if ( $o =~ /(["'])([^"']+)\1/ )
if ( $o =~ /"([^"]+)"/ )
{
$o = $2;
$o = $1;
}
#print " - remove quotes : $o ";
#
@@ -125,18 +125,13 @@ sub testFile
#
next if ( $o =~ /^[ \t]*$/ );
#
# Now split at pipe
#
foreach my $osplit (split(/\|/, $o)) {
#
# Phew. Now we're done.
#
# This option '$osplit' is something we call GetOptions with.
#
$accepted{$osplit} = 1;
}
#
# Phew. Now we're done.
#
# This option '$o' is something we call GetOptions with.
#
$accepted{$o} = 1;
}
}

View File

@@ -1,45 +0,0 @@
#!/usr/bin/perl -w
#
# Test that .gitignore is coherent
#
# Stéphane (kwisatz) Jourdois
# --
#
use strict;
use Test::More tests => 3;
BEGIN { use_ok( 'Git' ); }
# First, check that no tracked files are ignored
my $cmd = Git::command_output_pipe('ls-files', '--ignored', '--exclude-standard');
my $output;
while (<$cmd>) { $output .= "--> $_" }
close $cmd;
ok(!defined $output, 'No tracked file is ignored')
or diag(<<EOF
Check that the following tracked files _have_to_ be ignored, and then either :
- 'git rm' them
- modify .gitignore to not ignore them
EOF
. $output . "\n");
# Now, check that no untracked files are present
$cmd = Git::command_output_pipe('ls-files', '--others', '--exclude-standard');
undef $output;
while (<$cmd>) { $output .= "--> $_" }
close $cmd;
ok(!defined $output, 'No untracked file is present')
or diag(<<EOF
Check whether the following untracked files have to be ignored or
tracked, and either :
- 'git add' them
- modify .gitignore to ignore them
EOF
. $output . "\n");

View File

@@ -94,7 +94,7 @@ sub testHook
# 1:2345:respawn:/sbin/getty 38400 console
#
ok( $1 eq "1", "We found the first getty line." );
ok( $3 eq "hvc0", "Which does uses the correct driver: $3" );
ok( $3 eq "tty1", "Which does uses the correct driver: $3" );
}
if ( $line =~ /^(.).*getty/ )

View File

@@ -25,11 +25,10 @@ use Test::More qw( no_plan );
EOF
for i in `grep '^use ' -r .. | 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 POSIX | grep -v Xen:: | grep -v Moose | awk '{print $2}' | tr -d
\;\(\) | sort | uniq`; \
do \
echo "BEGIN{ use_ok( '$i' ); }"; \
echo "require_ok( '$i' );" ; \
printf '\n' ; \
done

80
t/modules.t Executable file
View File

@@ -0,0 +1,80 @@
#!/usr/bin/perl -w -I..
#
# Test that all the Perl modules we require are available.
#
# This list is automatically generated by modules.sh
#
# Steve
# --
#
use Test::More qw( no_plan );
BEGIN{ use_ok( 'Carp' ); }
require_ok( 'Carp' );
BEGIN{ use_ok( 'Config' ); }
require_ok( 'Config' );
BEGIN{ use_ok( 'Digest::MD5' ); }
require_ok( 'Digest::MD5' );
BEGIN{ use_ok( 'English' ); }
require_ok( 'English' );
BEGIN{ use_ok( 'Env' ); }
require_ok( 'Env' );
BEGIN{ use_ok( 'File::Copy' ); }
require_ok( 'File::Copy' );
BEGIN{ use_ok( 'File::Find' ); }
require_ok( 'File::Find' );
BEGIN{ use_ok( 'File::Path' ); }
require_ok( 'File::Path' );
BEGIN{ use_ok( 'File::Slurp' ); }
require_ok( 'File::Slurp' );
BEGIN{ use_ok( 'File::Spec' ); }
require_ok( 'File::Spec' );
BEGIN{ use_ok( 'File::Temp' ); }
require_ok( 'File::Temp' );
BEGIN{ use_ok( 'Getopt::Long' ); }
require_ok( 'Getopt::Long' );
BEGIN{ use_ok( 'Pod::Usage' ); }
require_ok( 'Pod::Usage' );
BEGIN{ use_ok( 'strict' ); }
require_ok( 'strict' );
BEGIN{ use_ok( 'Test::More' ); }
require_ok( 'Test::More' );
BEGIN{ use_ok( 'Text::Template' ); }
require_ok( 'Text::Template' );
BEGIN{ use_ok( 'warnings' ); }
require_ok( 'warnings' );

View File

@@ -38,15 +38,9 @@ sub checkFile
# Nor about Makefiles
return if ( $file =~ /\/Makefile$/ );
# Nor about dot files
return if ( $file =~ m{/\.[^/]+$} );
# Nor about files which start with ./debian/
return if ( $file =~ /^\.\/debian\// );
# Nor about Changlog
return if ( $file =~ /^\.\/ChangeLog$/ );
# Finally mercurial and git files are fine.
return if ( $file =~ /\.(hg|git)\// );
# See if it is a shell/perl file.

View File

@@ -11,7 +11,7 @@
use strict;
use File::Find;
use Test::More qw/ no_plan /;
use Test::More;
eval "use Moose";
plan skip_all => "Moose required for testing Perl syntax"
@@ -24,6 +24,8 @@ plan skip_all => "Moose required for testing Perl syntax"
#
find( { wanted => \&checkFile, no_chdir => 1 }, '.' );
done_testing();
#
# Check a file.
#
@@ -41,12 +43,6 @@ sub checkFile
# Nor about Makefiles
return if ( $file =~ /\/Makefile$/ );
# Nor about git files
return if ( $file =~ /^\.\/\.git\// );
# Nor about dot files
return if ( $file =~ m{/\.[^/]+$} );
# `modules.sh` is a false positive.
return if ( $file =~ /modules.sh$/ );

View File

@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
#
# Test that the POD we include in our scripts is valid, via the external
# podchecker command.
# podcheck command.
#
# Steve
# --

View File

@@ -2,8 +2,6 @@ use strict;
use warnings;
use Test::More;
push @INC, 'lib';
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";

View File

@@ -42,7 +42,6 @@ sub checkFile
# We're only testing things beneath hooks
return if ( $file !~ /hooks/ );
return if ( $file =~ /\.git/ );
# See if it is a shell script.
my $isShell = 0;
@@ -88,9 +87,9 @@ sub checkFile
is( $result, 0, "Shell script passes our portability check: $file" );
if (-x "/usr/bin/checkbashisms") {
# Check for bashisms
$result = `/usr/bin/checkbashisms '$file'`;
is( $result, '', "Shell script passes check for bashisms: $file" );
# Check for bashisms
$result = `/usr/bin/checkbashisms '$file'`;
is( $result, '', "Shell script passes check for bashisms: $file" );
}
}

View File

@@ -12,15 +12,12 @@ use Test::More qw( no_plan );
#
# Files that we want to use.
#
my @required = qw( /bin/ls /bin/dd /bin/mount /bin/cp /bin/tar );
my @required = qw( /usr/sbin/debootstrap /bin/ls /bin/dd /bin/mount /bin/cp /bin/tar );
#
# Files that we might wish to use.
#
my @optional = qw( /usr/sbin/debootstrap /usr/bin/rpmstrap /usr/sbin/xm
/sbin/mkfs.ext3 /sbin/mkfs.xfs /sbin/mkfs.reiserfs
/sbin/mkfs.btrfs
);
my @optional = qw( /usr/bin/rpmstrap /usr/sbin/xm /sbin/mkfs.ext3 /sbin/mkfs.xfs/sbin/mkfs.reiserfs );

View File

@@ -1,7 +1,6 @@
#!/usr/bin/perl -w
#
# Test that every bash script using variables uses " not ' around the
# variable.
# Test that every bash script using variables uses " not '.
#
# Steve
# --
@@ -72,7 +71,7 @@ sub checkFile
next if ( $line =~ /grep|sed|echo|awk|find|policy-rc.d|chroot|logMessage/ );
if ( $line =~ /\$/ )
{
ok( $line !~ /\'.*\$\.*\'/, "Non-masked line '$line' in '$file'" );
ok( $line !~ /\'/, "Non-masked line '$line'" );
}
}
close( FILE );

Some files were not shown because too many files have changed in this diff Show More