Sounds good.
Unless we get complaints in a couple of days, I say we add this to the
dev branch.
-Brian
Thus spake Dann Frazier ([EMAIL PROTECTED]):
> On Mon, Feb 17, 2003 at 08:49:42PM -0600, Brian Elliott Finley wrote:
> > Dann,
> >
> > Very interesting. Is this partially as a response to one of Gary's
> > requirements?
>
> Partially, yes. I originally started putting this together to help
> cleanup Server.pm - it became my hammer of the week, and Gary's problem
> looked like a nail.
>
> Lemme try to restate Gary's problem - he can jump in if I miss something.
> They have a single image, but with multiple client types (if i can coin
> some new sis terminology). By that I mean he has > 1 master script for
> this image. He customizes his master scripts in various ways, and will
> need to do so occasionally in the future. Currently, this means that a
> global change means editing a bunch of master scripts. These scripts
> can't be automatically regenerated, and its relatively easy to miss one
> when updating each of them.
>
> With this patch, he would have a template file to which he could add
> his global changes. He can then rerun mkautoinstallscript for each
> autoinstallscript.conf he needs, and have a fully reproduceable set
> of scripts. On upgrade, he could do a diff between the new default
> template and his own, and merge those changes back in.
>
> He still must remember all the options to pass to mkautoinstallscript,
> and keep track of all the client types that require autoinstallscript
> regeneration. This is where the SIS database would greatly help out,
> so that we can get to the point of running mkautoinstallscript -f --all,
> and it is able to lookup all the info it needs to do its job.
>
> There seems to be a general consensus that simple .master scripts are
> something we should stay with (I'm favoring this approach myself), and
> this is a way to do that. But our "power-users" can add whatever code
> they want to the template, and still have something maintainable.
>
> Looking way too far ahead, we could eventually give users the power to
> make their own "key words", and define modules to generate code for them
> instead of adding it inline to the template.
>
> (not trimming this, cause i'm not sure if Gary's seen it).
>
> > I do remember discussing this with you. I think I like the idea.
> >
> > Does anyone have any opposition to implementing this in the development
> > code?
> >
> > Here's my restatement of the idea (please correct me if I'm wrong, Dann):
> > o Provide a template for autoinstall scripts
> > o Include key words in the template, that mkautoinstallscript, or
> > any other script generation tool, would substitute for variable
> > information, as necessary.
> > o One advantage to this is that it allows the user to customize
> > their template, which would be persistent across aiscript
> > generations.
> > o Another benefit is that if we (the developers) decide to change
> > verbiage, it doesn't require us to actually modify the code --
> > just the template.
> > o And finally, a pet peeve of mine, it allows us to loose a lot of
> > print <<EOF; statements in the aiscript generation code.
> >
> > Everyone, omments, please. If you don't speak up, dann's going to
> > commit this thing... ;-)
> >
> > Cheers, -Brian
> >
> >
> >
> > Thus spake dann frazier ([EMAIL PROTECTED]):
> >
> > > hey,
> > > Here's a patch to remove a lot of the prints from the master script
> > > generation code, by placing static text in a template file that is
> > > parsed at runtime. This also has the side effect that users can modify
> > > this template and add arbitrary code if desired.
> > >
> > > Simply put, it reads lines in the template, and dumps them out to the
> > > master script file. When it hits a marker (for example, ##PARTITION_DISKS##),
> > > it will instead write out the appropriate code.
> > >
> > > I've attached a template file, as well as a Server.pm patch (which is
> > > reduced by 218 lines).
> > >
> > > Here's an annotated diff of a master script created from CVS HEAD, vs one
> > > created w/ CVS HEAD plus my patch (search for dannf).
> > >
> > > --- /var/lib/systemimager/scripts/longs-rhas.master 2003-02-05
>00:14:04.000000000 +0300
> > > +++ /var/lib/systemimager/scripts/test.master 2003-02-14 07:15:08.000000000
>+0300
> > > @@ -8,12 +8,16 @@
> > > #
> > > # This master autoinstall script was created with SystemImager v3.0.0bef1
> > >
> > > -VERSION=3.0.0bef1
> > > -
> > > dannf> I removed the VERSION string here, because its already above, and
> > > dannf> nowhere is this variable used. It was originally added for the
> > > dannf> versioning stuff that we decided to remove a while back, iirc.
> > >
> > > PATH=/sbin:/bin:/usr/bin:/usr/sbin:/tmp
> > > ARCH=`uname -m \
> > > | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/`
> > >
> > > +if [ -z $NO_LISTING ]; then
> > > + VERBOSE_OPT="v"
> > > +else
> > > + VERBOSE_OPT=""
> > > +fi
> > > +
> > >
> > > dannf> I moved the no_listing decision here because it makes some other
> > > dannf> stuff static that wouldn't otherwise be (the rsync/tar commands, for
> > > dannf> example). This means that stuff can be template fodder instead of
> > > dannf> dynamically generated code.
> > >
> > > shellout() {
> > > exec cat /etc/issue ; exit 1
> > > }
> > > @@ -84,7 +88,6 @@
> > > fi
> > > ### END Stop RAID devices before partitioning begins ###
> > >
> > > -
> > > ### BEGIN partition /dev/sda ###
> > > echo "Partitioning /dev/sda..."
> > > echo "Old partition table for /dev/sda:"
> > > @@ -180,7 +183,7 @@
> > > ### END partition /dev/sdc ###
> > >
> > >
> > > -### BEGIN swap and filesystem creation commands ###
> > > +
> > > echo "Load additional filesystem drivers."
> > > modprobe reiserfs
> > > modprobe ext2
> > > @@ -188,6 +191,7 @@
> > > modprobe jfs
> > > modprobe xfs
> > >
> > > +### BEGIN swap and filesystem creation commands ###
> > > echo "mke2fs -j /dev/sdc1 || shellout"
> > >
> > >
> > > mke2fs -j /dev/sdc1 || shellout
> > > echo "tune2fs -L / /dev/sdc1"
> > > @@ -219,20 +221,37 @@
> > > mount proc /a/proc -t proc -o defaults || shellout
> > > ### END mount proc in image for tools like System Configurator ###
> > >
> > > +if [ $NO_LISTING ]; then
> > > + echo -n "Quietly installing image...|"
> > > + { while :; do
> > > + echo -ne "\b/"; sleep 1;
> > > + echo -ne "\b-"; sleep 1;
> > > + echo -ne "\b\\"; sleep 1;
> > > + echo -ne "\b|"; sleep 1;
> > > + done
> > > + }&
> > > + pid=$!
> > > +fi
> > >
> > > # Filler up!
> > > if [ ! -z $PORTBASE ]; then
> > > # Use multicast
> > > mcast_group+2
> > > - echo "udp-receiver --pipe 'tar -x -C /a' --portbase ${PORTBASE}"
> > > - udp-receiver --pipe 'tar -x -C /a' --portbase ${PORTBASE} || shellout
> > > + echo "udp-receiver --pipe 'tar -x${VERBOSE_OPT} -C /a' --portbase
>${PORTBASE}"
> > > + udp-receiver --pipe 'tar -x${VERBOSE_OPT} -C /a' --portbase ${PORTBASE} ||
>shellout
> > >
> > > else
> > > # Use rsync
> > > - echo "rsync -av --exclude=lost+found/ --numeric-ids
>${IMAGESERVER}::${IMAGENAME}/ /a/"
> > > - rsync -av --exclude=lost+found/ --numeric-ids ${IMAGESERVER}::${IMAGENAME}/
>/a/ || shellout
> > > + echo "rsync -a${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
>${IMAGESERVER}::${IMAGENAME}/ /a/"
> > > + rsync -a${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
>${IMAGESERVER}::${IMAGENAME}/ /a/ || shellout
> > >
> > > fi
> > >
> > > dannf> this is different because ${VERBOSE_OPT} has been added
> > > +
> > > +if [ $NO_LISTING ]; then
> > > + kill $pid
> > > + echo "done."
> > > +fi
> > > +
> > > # Leave notice of which image is installed on the client
> > > echo $IMAGENAME > /a/etc/systemimager/IMAGE_LAST_SYNCED_TO || shellout
> > >
> > > @@ -285,8 +304,7 @@
> > >
> > > ### BEGIN systemconfigurator ###
> > > # Configure the client's hardware, network interface, and boot loader.
> > > -chroot /a/ systemconfigurator --configsi --stdin <<EOL || shellout
> > > -
> > > +chroot /a/ systemconfigurator
>--excludesto=/etc/systemimager/systemconfig.local.exclude --configsi --stdin << EOF
>|| shellout
> > > dannf> this was a pseudo-bug fix. --excludesto was only being added in a
> > > dannf> particular case, when it was intended to be added all the time.
> > > [NETWORK]
> > > HOSTNAME = $HOSTNAME
> > > DOMAINNAME = $DOMAINNAME
> > > @@ -328,5 +346,3 @@
> > > sleep 1
> > > count=$(($count + 1))
> > > done
> > > -
> > > -
> > >
> > > --
> > > ---------------------------
> > > dann frazier
> > > Hewlett-Packard
> > > Linux Systems Division
> > > [EMAIL PROTECTED]
> > > (970) 898-0800
> >
> > > Index: lib/SystemImager/Server.pm
> > > ===================================================================
> > > RCS file: /cvsroot/systemimager/systemimager/lib/SystemImager/Server.pm,v
> > > retrieving revision 1.62
> > > diff -u -p -u -r1.62 Server.pm
> > > --- lib/SystemImager/Server.pm 5 Feb 2003 02:58:19 -0000 1.62
> > > +++ lib/SystemImager/Server.pm 14 Feb 2003 04:44:11 -0000
> > > @@ -188,10 +188,10 @@ sub get_part_name {
> > > }
> > >
> > > # Usage:
> > > -# _read_partition_info_and_prepare_parted_commands( $image_dir,
>$auto_install_script_conf );
> > > +# _read_partition_info_and_prepare_parted_commands( $out, $image_dir,
>$auto_install_script_conf );
> > > sub _read_partition_info_and_prepare_parted_commands {
> > >
> > > - my ($image_dir, $file) = @_;
> > > + my ($out, $image_dir, $file) = @_;
> > >
> > > my $xml_config = XMLin($file, keyattr => { disk => "+dev", part => "+num"
>}, forcearray => 1 );
> > >
> > > @@ -214,21 +214,21 @@ sub _read_partition_info_and_prepare_par
> > >
> > > my $devfs_dev = &dev_to_devfs($dev);
> > >
> > > - print MASTER_SCRIPT "### BEGIN partition $devfs_dev ###\n";
> > > - print MASTER_SCRIPT qq(echo "Partitioning $devfs_dev..."\n);
> > > - print MASTER_SCRIPT qq(echo "Old partition table for $devfs_dev:"\n);
> > > - print MASTER_SCRIPT "parted -s -- $devfs_dev print\n\n";
> > > + print $out "### BEGIN partition $devfs_dev ###\n";
> > > + print $out qq(echo "Partitioning $devfs_dev..."\n);
> > > + print $out qq(echo "Old partition table for $devfs_dev:"\n);
> > > + print $out "parted -s -- $devfs_dev print\n\n";
> > >
> > > - print MASTER_SCRIPT "# Create disk label. This ensures that all
>remnants of the old label, whatever\n";
> > > - print MASTER_SCRIPT "# type it was, are removed and that we're starting
>with a clean label.\n";
> > > + print $out "# Create disk label. This ensures that all remnants of the
>old label, whatever\n";
> > > + print $out "# type it was, are removed and that we're starting with a
>clean label.\n";
> > > $cmd = "parted -s -- $devfs_dev mklabel $label_type || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n\n";
> > >
> > > - print MASTER_SCRIPT "# Get the size of the destination disk so that we
>can make the partitions fit properly.\n";
> > > - print MASTER_SCRIPT qq(DISK_SIZE=`parted -s $devfs_dev print ) . q(|
>grep 'Disk geometry for' | sed 's/^.*-//g' | sed 's/\..*$//' `) . qq(\n);
> > > - print MASTER_SCRIPT q([ -z $DISK_SIZE ] && shellout) . qq(\n);
> > > - print MASTER_SCRIPT qq(END_OF_LAST_PRIMARY=0\n);
> > > + print $out "# Get the size of the destination disk so that we can make
>the partitions fit properly.\n";
> > > + print $out qq(DISK_SIZE=`parted -s $devfs_dev print ) . q(| grep 'Disk
>geometry for' | sed 's/^.*-//g' | sed 's/\..*$//' `) . qq(\n);
> > > + print $out q([ -z $DISK_SIZE ] && shellout) . qq(\n);
> > > + print $out qq(END_OF_LAST_PRIMARY=0\n);
> > >
> > > ### BEGIN Populate the simple hashes. -BEF- ###
> > > my (
> > > @@ -471,14 +471,14 @@ sub _read_partition_info_and_prepare_par
> > > unless ($endMB{$m}) { next; }
> > >
> > > ### Print partitioning commands. -BEF-
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > > $part = &get_part_name($dev, $m);
> > > $cmd = "Creating partition $part.";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > + print $out qq(echo "$cmd"\n);
> > >
> > > - print MASTER_SCRIPT qq(START_MB=$startMB{$m}\n);
> > > - print MASTER_SCRIPT qq(END_MB=$endMB{$m}\n);
> > > + print $out qq(START_MB=$startMB{$m}\n);
> > > + print $out qq(END_MB=$endMB{$m}\n);
> > >
> > > if($p_type{$m} eq "extended") {
> > >
> > > @@ -494,19 +494,19 @@ sub _read_partition_info_and_prepare_par
> > > $cmd = qq(parted -s -- $devfs_dev mkpart $p_type{$m} ext2 ) .
>q($START_MB $END_MB) . qq( || shellout);
> > >
> > > }
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # Leave info behind for the next partition. -BEF-
> > > if ("$p_type{$m}" eq "primary") {
> > > - print MASTER_SCRIPT q(END_OF_LAST_PRIMARY=$END_MB) . qq(\n);
> > > + print $out q(END_OF_LAST_PRIMARY=$END_MB) . qq(\n);
> > >
> > > } elsif ("$p_type{$m}" eq "extended") {
> > > - print MASTER_SCRIPT q(END_OF_LAST_PRIMARY=$END_MB) . qq(\n);
> > > - print MASTER_SCRIPT q(END_OF_LAST_LOGICAL=$START_MB) . qq(\n);
> > > + print $out q(END_OF_LAST_PRIMARY=$END_MB) . qq(\n);
> > > + print $out q(END_OF_LAST_LOGICAL=$START_MB) . qq(\n);
> > >
> > > } elsif ("$p_type{$m}" eq "logical") {
> > > - print MASTER_SCRIPT q(END_OF_LAST_LOGICAL=$END_MB) . qq(\n);
> > > + print $out q(END_OF_LAST_LOGICAL=$END_MB) . qq(\n);
> > > }
> > >
> > > #
> > > @@ -516,9 +516,9 @@ sub _read_partition_info_and_prepare_par
> > > # partition. -BEF-
> > > #
> > > if ($id{$m}) {
> > > - print MASTER_SCRIPT qq(# Use sfdisk to change the partition id.
> parted is\n);
> > > - print MASTER_SCRIPT qq(# incapable of this particular
>operation.\n);
> > > - print MASTER_SCRIPT qq(sfdisk --change-id $devfs_dev $m $id{$m}
>\n);
> > > + print $out qq(# Use sfdisk to change the partition id. parted
>is\n);
> > > + print $out qq(# incapable of this particular operation.\n);
> > > + print $out qq(sfdisk --change-id $devfs_dev $m $id{$m} \n);
> > > }
> > >
> > > # Name any partitions that need that kinda treatment.
> > > @@ -536,8 +536,8 @@ sub _read_partition_info_and_prepare_par
> > > ) { # We're kinda assuming no one names their partitions "-".
>-BEF-
> > >
> > > $cmd = "parted -s -- $devfs_dev name $m $p_name{$m} ||
>shellout\n";
> > > - print MASTER_SCRIPT "echo $cmd";
> > > - print MASTER_SCRIPT "$cmd";
> > > + print $out "echo $cmd";
> > > + print $out "$cmd";
> > > }
> > >
> > > ### Deal with flags for each partition. -BEF-
> > > @@ -550,153 +550,31 @@ sub _read_partition_info_and_prepare_par
> > > # Parted 1.6.0 doesn't seem to want to tag gpt partitions
>with lba. Hmmm. -BEF-
> > > if (($flag eq "lba") and ($label_type eq "gpt")) { next; }
> > > $cmd = "parted -s -- $devfs_dev set $m $flag on ||
>shellout\n";
> > > - print MASTER_SCRIPT "echo $cmd";
> > > - print MASTER_SCRIPT "$cmd";
> > > + print $out "echo $cmd";
> > > + print $out "$cmd";
> > > }
> > > }
> > > }
> > >
> > > # Kick the minors out. (remove temporary partitions) -BEF-
> > > foreach $m (keys %minors_to_remove) {
> > > - print MASTER_SCRIPT "\n# Gotta lose this one (${dev}${m}) to make the
>disk look right.\n";
> > > + print $out "\n# Gotta lose this one (${dev}${m}) to make the disk
>look right.\n";
> > > $cmd = "parted -s -- $devfs_dev rm $m || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > }
> > >
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT qq(echo "New partition table for $devfs_dev:"\n);
> > > + print $out "\n";
> > > + print $out qq(echo "New partition table for $devfs_dev:"\n);
> > > $cmd = "parted -s -- $devfs_dev print";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > - print MASTER_SCRIPT "### END partition $devfs_dev ###\n";
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT "\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > + print $out "### END partition $devfs_dev ###\n";
> > > + print $out "\n";
> > > + print $out "\n";
> > > }
> > > }
> > >
> > > -
> > > -sub _in_script_add_standard_header_stuff {
> > > - my ($image, $script_name) = @_;
> > > - print MASTER_SCRIPT << 'EOF';
> > > -#!/bin/sh
> > > -
> > > -#
> > > -# "SystemImager"
> > > -#
> > > -# Copyright (C) 1999-2001 Brian Elliott Finley
><[EMAIL PROTECTED]>
> > > -# Copyright (C) 2002 Bald Guy Software <[EMAIL PROTECTED]>
> > > -#
> > > -EOF
> > > -
> > > - print MASTER_SCRIPT "# This master autoinstall script was created with
>SystemImager v$VERSION\n";
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT "VERSION=$VERSION\n";
> > > -
> > > - print MASTER_SCRIPT << 'EOF';
> > > -
> > > -PATH=/sbin:/bin:/usr/bin:/usr/sbin:/tmp
> > > -ARCH=`uname -m \
> > > -| sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/`
> > > -
> > > -shellout() {
> > > - exec cat /etc/issue ; exit 1
> > > -}
> > > -
> > > -mcast_group+2() {
> > > - PORTBASE=$(echo "scale=3; ($PORTBASE + 2)" | bc)
> > > -}
> > > -
> > > -# Pull in variables left behind by the linuxrc script.
> > > -# This information is passed from the linuxrc script on the autoinstall media
> > > -# via /tmp/variables.txt. Apparently the shell we use in BOEL is not
> > > -# intelligent enough to take a "set -a" parameter.
> > > -#
> > > -. /tmp/variables.txt || shellout
> > > -
> > > -EOF
> > > -
> > > - print MASTER_SCRIPT q([ -z $IMAGENAME ] && ) . qq(IMAGENAME=$image\n);
> > > - print MASTER_SCRIPT q([ -z $OVERRIDES ] && ) .
>qq(OVERRIDES="$script_name"\n);
> > > - print MASTER_SCRIPT << 'EOF';
> > > -
> > > -### BEGIN Check to be sure this not run from a working machine ###
> > > -# Test for mounted SCSI or IDE disks
> > > -mount | grep [hs]d[a-z][1-9] > /dev/null 2>&1
> > > -[ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
> > > -
> > > -# Test for mounted software RAID devices
> > > -mount | grep md[0-9] > /dev/null 2>&1
> > > -[ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
> > > -
> > > -# Test for mounted hardware RAID disks
> > > -mount | grep c[0-9]+d[0-9]+p > /dev/null 2>&1
> > > -[ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
> > > -### END Check to be sure this not run from a working machine ###
> > > -
> > > -
> > > -### BEGIN Stop RAID devices before partitioning begins ###
> > > -# Q1) Why did they get started in the first place?
> > > -# A1) So we can pull a local.cfg file off a root mounted software RAID system.
> > > -# They may not be started on your system -- they would only be started if
> > > -# you did the stuff in Q3 below.
> > > -#
> > > -# Q2) Why didn't my local.cfg on my root mounted software RAID work for me
> > > -# with the standard kernel flavour?
> > > -# A2) The standard kernel flavour uses modules for the software RAID drivers --
> > > -# therefore, software RAID is not available at the point in the boot process
> > > -# where BOEL needs to read the local.cfg file. They are only pulled over
> > > -# when this script is run, which is, of course, only runnable if it was
> > > -# pulled over the network using the settings that you would have wanted it
> > > -# to get from the local.cfg file, which it couldn't. Right?
> > > -#
> > > -# Q3) Whatever. So how do I make it work with a local.cfg file on my root
> > > -# mounted software RAID?
> > > -# A3) Compile an autoinstall kernel with software RAID, and any other drivers
> > > -# you might need built in (filesystem, SCSI drivers, etc.).
> > > -#
> > > -# Find running raid devices
> > > -if [ -f /proc/mdstat ]; then
> > > - RAID_DEVICES=` cat /proc/mdstat | grep ^md | sed 's/ .*$//g' `
> > > -
> > > - # raidstop will not run unless a raidtab file exists
> > > - echo "" >> /etc/raidtab || shellout
> > > -
> > > - # turn dem pesky raid devices off!
> > > - for RAID_DEVICE in ${RAID_DEVICES}
> > > - do
> > > - DEV="/dev/${RAID_DEVICE}"
> > > - # we don't do a shellout here because, well I forgot why, but we don't.
> > > - echo "raidstop ${DEV}" && raidstop ${DEV}
> > > - done
> > > -fi
> > > -### END Stop RAID devices before partitioning begins ###
> > > -
> > > -
> > > -EOF
> > > -}
> > > -
> > > -
> > > -sub _mount_proc_in_image_on_client {
> > > -
> > > - # The following allows a proc filesystem to be mounted in the fakeroot.
> > > - # This provides /proc to programs which are called by SystemImager
> > > - # (eg. System Configurator).
> > > -
> > > - print MASTER_SCRIPT "### BEGIN mount proc in image for tools like System
>Configurator ###\n";
> > > - my $cmd = "mkdir -p /a/proc || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > - $cmd = "mount proc /a/proc -t proc -o defaults || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > - print MASTER_SCRIPT "### END mount proc in image for tools like System
>Configurator ###\n";
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT "\n";
> > > -
> > > -}
> > > -
> > > -
> > > # Usage:
> > > # upgrade_partition_schemes_to_generic_style($image_dir, $config_dir);
> > > sub upgrade_partition_schemes_to_generic_style {
> > > @@ -830,7 +708,7 @@ sub dev_to_devfs {
> > > #
> > > sub _write_out_mkfs_commands {
> > >
> > > - my ($image_dir, $file) = @_;
> > > + my ($out, $image_dir, $file) = @_;
> > >
> > > my $xml_config = XMLin($file, keyattr => { fsinfo => "+line" }, forcearray
>=> 1 );
> > >
> > > @@ -851,47 +729,37 @@ sub _write_out_mkfs_commands {
> > > }
> > > }
> > >
> > > - print MASTER_SCRIPT "### BEGIN swap and filesystem creation commands ###\n";
> > > - print MASTER_SCRIPT qq(echo "Load additional filesystem drivers."\n);
> > > - print MASTER_SCRIPT "modprobe reiserfs\n";
> > > - print MASTER_SCRIPT "modprobe ext2\n";
> > > - print MASTER_SCRIPT "modprobe ext3\n";
> > > - print MASTER_SCRIPT "modprobe jfs\n";
> > > - print MASTER_SCRIPT "modprobe xfs\n";
> > > - print MASTER_SCRIPT "\n";
> > > -
> > > -
> > > if ($software_raid) {
> > >
> > > - print MASTER_SCRIPT qq(# Must remove the /etc/raidtab created for the
>raidstop commands above.\n);
> > > - print MASTER_SCRIPT qq(rm -f /etc/raidtab\n);
> > > - print MASTER_SCRIPT qq(echo\n);
> > > - print MASTER_SCRIPT qq(echo "Pull /etc/raidtab in image over to
>autoinstall client."\n);
> > > - print MASTER_SCRIPT qq(rsync -av --numeric-ids
>\$IMAGESERVER::\$IMAGENAME/etc/raidtab /etc/raidtab || echo "No /etc/raidtab in the
>image directory, hopefully there's one in an override directory."\n);
> > > + print $out qq(# Must remove the /etc/raidtab created for the raidstop
>commands above.\n);
> > > + print $out qq(rm -f /etc/raidtab\n);
> > > + print $out qq(echo\n);
> > > + print $out qq(echo "Pull /etc/raidtab in image over to autoinstall
>client."\n);
> > > + print $out qq(rsync -av --numeric-ids
>\$IMAGESERVER::\$IMAGENAME/etc/raidtab /etc/raidtab || echo "No /etc/raidtab in the
>image directory, hopefully there's one in an override directory."\n);
> > >
> > > - print MASTER_SCRIPT qq(echo "Pull /etc/raidtab from each override to
>autoinstall client."\n);
> > > - print MASTER_SCRIPT q(for OVERRIDE in $OVERRIDES) . qq(\n);
> > > - print MASTER_SCRIPT qq(do\n);
> > > - print MASTER_SCRIPT q( rsync -av --numeric-ids
>$IMAGESERVER::overrides/$OVERRIDE/etc/raidtab /etc/raidtab || echo "No /etc/raidtab
>in override $OVERRIDE, but that should be OK.") . qq(\n);
> > > - print MASTER_SCRIPT qq( echo\n);
> > > - print MASTER_SCRIPT qq(done\n);
> > > -
> > > - print MASTER_SCRIPT qq(if [ -e /etc/raidtab ]; then\n);
> > > - print MASTER_SCRIPT qq( echo "Ah, good. Found an /etc/raidtab
>file. Proceeding..."\n);
> > > - print MASTER_SCRIPT qq(else\n);
> > > - print MASTER_SCRIPT qq( echo "No /etc/raidtab file. Please verify
>that you have one in your image, or in an override directory."\n);
> > > - print MASTER_SCRIPT qq( shellout\n);
> > > - print MASTER_SCRIPT qq(fi\n);
> > > -
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT "# Load RAID modules, if necessary, and create
>software RAID devices.\n";
> > > - print MASTER_SCRIPT "if [ ! -f /proc/mdstat ]; then\n";
> > > - print MASTER_SCRIPT " modprobe linear\n";
> > > - print MASTER_SCRIPT " modprobe raid0\n";
> > > - print MASTER_SCRIPT " modprobe raid1\n";
> > > - print MASTER_SCRIPT " modprobe raid5\n";
> > > - print MASTER_SCRIPT "fi\n";
> > > - print MASTER_SCRIPT "\n";
> > > + print $out qq(echo "Pull /etc/raidtab from each override to autoinstall
>client."\n);
> > > + print $out q(for OVERRIDE in $OVERRIDES) . qq(\n);
> > > + print $out qq(do\n);
> > > + print $out q( rsync -av --numeric-ids
>$IMAGESERVER::overrides/$OVERRIDE/etc/raidtab /etc/raidtab || echo "No /etc/raidtab
>in override $OVERRIDE, but that should be OK.") . qq(\n);
> > > + print $out qq( echo\n);
> > > + print $out qq(done\n);
> > > +
> > > + print $out qq(if [ -e /etc/raidtab ]; then\n);
> > > + print $out qq( echo "Ah, good. Found an /etc/raidtab file.
>Proceeding..."\n);
> > > + print $out qq(else\n);
> > > + print $out qq( echo "No /etc/raidtab file. Please verify that you
>have one in your image, or in an override directory."\n);
> > > + print $out qq( shellout\n);
> > > + print $out qq(fi\n);
> > > +
> > > + print $out "\n";
> > > + print $out "# Load RAID modules, if necessary, and create software RAID
>devices.\n";
> > > + print $out "if [ ! -f /proc/mdstat ]; then\n";
> > > + print $out " modprobe linear\n";
> > > + print $out " modprobe raid0\n";
> > > + print $out " modprobe raid1\n";
> > > + print $out " modprobe raid5\n";
> > > + print $out "fi\n";
> > > + print $out "\n";
> > >
> > > }
> > >
> > > @@ -928,7 +796,7 @@ sub _write_out_mkfs_commands {
> > >
> > > # software RAID devices (/dev/md*)
> > > if ($real_dev =~ /\/dev\/md/) {
> > > - print MASTER_SCRIPT qq(mkraid --really-force $real_dev ||
>shellout\n);
> > > + print $out qq(mkraid --really-force $real_dev || shellout\n);
> > > }
> > >
> > > # swap
> > > @@ -936,35 +804,35 @@ sub _write_out_mkfs_commands {
> > >
> > > # create swap
> > > $cmd = "mkswap -v1 $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # swapon
> > > $cmd = "swapon $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > > # msdos or vfat
> > > } elsif (( $xml_config->{fsinfo}->{$line}->{fs} eq "vfat" ) or (
>$xml_config->{fsinfo}->{$line}->{fs} eq "msdos" )){
> > >
> > > # create fs
> > > $cmd = "mkdosfs $mkfs_opts -v $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mkdir
> > > $cmd = "mkdir -p /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mount
> > > $cmd = "mount $real_dev /a$mp -t $fs -o $options || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > >
> > > # ext2
> > > @@ -972,8 +840,8 @@ sub _write_out_mkfs_commands {
> > >
> > > # create fs
> > > $cmd = "mke2fs $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > if ($mount_dev) {
> > > # add LABEL if necessary
> > > @@ -982,8 +850,8 @@ sub _write_out_mkfs_commands {
> > > $label =~ s/LABEL=//;
> > >
> > > $cmd = "tune2fs -L $label $real_dev";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > }
> > >
> > > # add UUID if necessary
> > > @@ -992,22 +860,22 @@ sub _write_out_mkfs_commands {
> > > $uuid =~ s/UUID=//;
> > >
> > > $cmd = "tune2fs -U $uuid $real_dev";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > }
> > > }
> > >
> > > # mkdir
> > > $cmd = "mkdir -p /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mount
> > > $cmd = "mount $real_dev /a$mp -t $fs -o $options || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > >
> > > # ext3
> > > @@ -1015,8 +883,8 @@ sub _write_out_mkfs_commands {
> > >
> > > # create fs
> > > $cmd = "mke2fs -j $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > if ($mount_dev) {
> > > # add LABEL if necessary
> > > @@ -1025,8 +893,8 @@ sub _write_out_mkfs_commands {
> > > $label =~ s/LABEL=//;
> > >
> > > $cmd = "tune2fs -L $label $real_dev";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > }
> > >
> > > # add UUID if necessary
> > > @@ -1035,22 +903,22 @@ sub _write_out_mkfs_commands {
> > > $uuid =~ s/UUID=//;
> > >
> > > $cmd = "tune2fs -U $uuid $real_dev";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > }
> > > }
> > >
> > > # mkdir
> > > $cmd = "mkdir -p /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mount
> > > $cmd = "mount $real_dev /a$mp -t $fs -o $options || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > >
> > > # reiserfs
> > > @@ -1058,68 +926,64 @@ sub _write_out_mkfs_commands {
> > >
> > > # create fs
> > > $cmd = "echo y | mkreiserfs $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mkdir
> > > $cmd = "mkdir -p /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mount
> > > $cmd = "mount $real_dev /a$mp -t $fs -o $options || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > > # jfs
> > > } elsif ( $xml_config->{fsinfo}->{$line}->{fs} eq "jfs" ) {
> > >
> > > # create fs
> > > $cmd = "mkfs.jfs -q $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mkdir
> > > $cmd = "mkdir -p /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mount
> > > $cmd = "mount $real_dev /a$mp -t $fs -o $options || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > > # xfs
> > > } elsif ( $xml_config->{fsinfo}->{$line}->{fs} eq "xfs" ) {
> > >
> > > # create fs
> > > $cmd = "mkfs.xfs -f -q $real_dev || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mkdir
> > > $cmd = "mkdir -p /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > # mount
> > > $cmd = "mount $real_dev /a$mp -t $fs -o $options || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > >
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "\n";
> > >
> > > }
> > >
> > > }
> > > -
> > > - print MASTER_SCRIPT "### END swap and filesystem creation commands ###\n";
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT "\n";
> > > }
> > >
> > >
> > > @@ -1168,14 +1032,11 @@ sub validate_auto_install_script_conf {
> > > #
> > > sub _write_out_new_fstab_file {
> > >
> > > - my ($image_dir, $file) = @_;
> > > + my ($out, $image_dir, $file) = @_;
> > >
> > > my $xml_config = XMLin($file, keyattr => { fsinfo => "+line" }, forcearray
>=> 1 );
> > >
> > > - print MASTER_SCRIPT qq(\n);
> > > - print MASTER_SCRIPT qq(\n);
> > > - print MASTER_SCRIPT qq(### BEGIN generate new fstab file from
>autoinstallscript.conf ###\n);
> > > - print MASTER_SCRIPT qq(cat <<'EOF' > /a/etc/fstab\n);
> > > + print $out qq(cat <<'EOF' > /a/etc/fstab\n);
> > >
> > > foreach my $line (sort numerically (keys ( %{$xml_config->{fsinfo}} ))) {
> > > my $comment = $xml_config->{fsinfo}->{$line}->{comment};
> > > @@ -1189,15 +1050,15 @@ sub _write_out_new_fstab_file {
> > > my $pass = $xml_config->{fsinfo}->{$line}->{pass};
> > >
> > > if ($comment) {
> > > - print MASTER_SCRIPT qq($comment\n);
> > > + print $out qq($comment\n);
> > >
> > > } else {
> > > - print MASTER_SCRIPT qq($mount_dev\t$mp\t$fs);
> > > + print $out qq($mount_dev\t$mp\t$fs);
> > > if ($options)
> > > - { print MASTER_SCRIPT qq(\t$options); }
> > > + { print $out qq(\t$options); }
> > >
> > > if (defined $dump) {
> > > - print MASTER_SCRIPT qq(\t$dump);
> > > + print $out qq(\t$dump);
> > >
> > > #
> > > # If dump don't exist, we certainly don't want to print pass
> > > @@ -1206,16 +1067,13 @@ sub _write_out_new_fstab_file {
> > > # defined.
> > > #
> > > if (defined $pass)
> > > - { print MASTER_SCRIPT qq(\t$pass); }
> > > + { print $out qq(\t$pass); }
> > > }
> > >
> > > - print MASTER_SCRIPT qq(\n);
> > > + print $out qq(\n);
> > > }
> > > }
> > > - print MASTER_SCRIPT qq(EOF\n);
> > > - print MASTER_SCRIPT qq(### END generate new fstab file from
>autoinstallscript.conf ###\n);
> > > - print MASTER_SCRIPT qq(\n);
> > > - print MASTER_SCRIPT qq(\n);
> > > + print $out qq(EOF\n);
> > > }
> > >
> > >
> > > @@ -1242,12 +1100,10 @@ sub numerically {
> > > #
> > > sub _write_out_umount_commands {
> > >
> > > - my ($image_dir, $file) = @_;
> > > + my ($out, $image_dir, $file) = @_;
> > >
> > > my $xml_config = XMLin($file, keyattr => { fsinfo => "+line" }, forcearray
>=> 1 );
> > >
> > > - print MASTER_SCRIPT "### BEGIN Unmount filesystems ###\n";
> > > -
> > > # We can't use mp as a hash key, because not all fsinfo lines will have an
> > > # mp entry. Associate filesystems by mount points in a hash here, then we
> > > # can reverse sort by mount point below to unmount them all. -BEF-
> > > @@ -1303,17 +1159,67 @@ sub _write_out_umount_commands {
> > >
> > > # umount
> > > my $cmd = "umount /a$mp || shellout";
> > > - print MASTER_SCRIPT qq(echo "$cmd"\n);
> > > - print MASTER_SCRIPT "$cmd\n";
> > > - print MASTER_SCRIPT "\n";
> > > + print $out qq(echo "$cmd"\n);
> > > + print $out "$cmd\n";
> > > + print $out "\n";
> > > +
> > > + }
> > > +}
> > > +
> > > +sub write_sc_command {
> > > + my ( $out, $ip_assignment_method ) = @_;
> > > + my $sc_excludes_to = "/etc/systemimager/systemconfig.local.exclude";
> > > + my $sc_cmd = "chroot /a/ systemconfigurator --excludesto=$sc_excludes_to";
> > > + if ($ip_assignment_method eq "replicant") {
> > > + $sc_cmd .= " --runboot";
> > > + }
> > > + else {
> > > + ## FIXME - is --excludesto only for the static method?
> > > + ## currently,
> > > + $sc_cmd .= " --configsi --stdin << EOF";
> > > + }
> > > + $sc_cmd .= " || shellout";
> > > +
> > > + print $out "$sc_cmd\n";
> > > +
> > > + unless ($ip_assignment_method eq "replicant") {
> > > + print $out "[NETWORK]\n";
> > > + print $out "HOSTNAME = \$HOSTNAME\n";
> > > + print $out "DOMAINNAME = \$DOMAINNAME\n";
> > > + }
> > > + if ($ip_assignment_method eq "static") {
> > > + print $out "GATEWAY = \$GATEWAY\n";
> > > + }
> > > + print $out "\n";
> > >
> > > + print $out "[INTERFACE0]\n";
> > > + print $out "DEVICE = eth0\n";
> > > +
> > > + if ($ip_assignment_method eq "dhcp") {
> > > + print $out "TYPE = dhcp\n";
> > > + }
> > > + elsif ($ip_assignment_method eq "static") {
> > > + print $out "TYPE = static\n";
> > > + print $out "IPADDR = \$IPADDR\n";
> > > + print $out "NETMASK = \$NETMASK\n";
> > > }
> > >
> > > - print MASTER_SCRIPT "### END Unmount filesystems ###\n";
> > > - print MASTER_SCRIPT "\n";
> > > - print MASTER_SCRIPT "\n";
> > > + print $out "EOL\n";
> > > }
> > >
> > > +my $beep_code = <<'EOL';
> > > +# Cause the system to make noise and display an "I'm done." message
> > > +ralph="sick"
> > > +count="1"
> > > +while [ $ralph="sick" ]
> > > +do
> > > + echo -n -e "\\a"
> > > + [ $count -lt 60 ] && echo "I've been done for $count seconds. Reboot me
>already!"
> > > + [ $(($count / 60 * 60)) = $count ] && echo "I've been done for $(($count /
>60)) minutes now. Reboot me already!"
> > > + sleep 1
> > > + count=$(($count + 1))
> > > +done
> > > +EOL
> > >
> > > sub create_autoinstall_script{
> > >
> > > @@ -1333,7 +1239,6 @@ sub create_autoinstall_script{
> > >
> > > my $cmd;
> > >
> > > - my $rsync_opts = "-aHS";
> > > # Truncate the /etc/mtab file. It can cause confusion on the autoinstall
> > > # client, making it think that filesystems are mounted when they really
> > > # aren't. And because it is automatically updated on running systems, we
> > > @@ -1350,67 +1255,71 @@ sub create_autoinstall_script{
> > > }
> > >
> > > $file = "$auto_install_script_dir/$script_name.master";
> > > - open (MASTER_SCRIPT, ">$file") || die "Can't open $file for writing\n";
> > > -
> > > - _in_script_add_standard_header_stuff($image, $script_name);
> > > -
> > > - _read_partition_info_and_prepare_parted_commands( $image_dir,
>$auto_install_script_conf );
> > > -
> > > - _write_out_mkfs_commands( $image_dir, $auto_install_script_conf );
> > > -
> > > - _mount_proc_in_image_on_client();
> > > -
> > > - if ($no_listing) {
> > > -
> > > - # Display a spinner instead of the standard file listing. A dannf
>feature. -BEF-
> > > - print MASTER_SCRIPT q(echo -n "Quietly installing image...|") . "\n";
> > > - print MASTER_SCRIPT q({ while :; do) . "\n";
> > > - print MASTER_SCRIPT q(echo -ne "\b/"; sleep 1;) . "\n";
> > > - print MASTER_SCRIPT q(echo -ne "\b-"; sleep 1;) . "\n";
> > > - print MASTER_SCRIPT q(echo -ne "\b\\\"; sleep 1;) . "\n";
> > > - print MASTER_SCRIPT q(echo -ne "\b|"; sleep 1;) . "\n";
> > > - print MASTER_SCRIPT q(done) . "\n";
> > > - print MASTER_SCRIPT q(}&) . "\n";
> > > - print MASTER_SCRIPT q(pid=$!) . "\n";
> > > -
> > > - } else {
> > > -
> > > - # Display the standard file listing. -BEF-
> > > - $rsync_opts .= "v";
> > > + my $template = "/etc/systemimager/master.template";
> > > + open (my $TEMPLATE, "<$template") || die "Can't open $template for
>reading\n";
> > > + open (my $MASTER_SCRIPT, ">$file") || die "Can't open $file for writing\n";
> > > +
> > > + my $delim = '##';
> > > + while (<$TEMPLATE>) {
> > > + SWITCH: {
> > > + if (/^\s*${delim}VERSION${delim}\s*$/) {
> > > + print $MASTER_SCRIPT "# This master autoinstall script was created with
>SystemImager v${VERSION}\n";
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}PARTITION_DISKS${delim}\s*$/) {
> > > + _read_partition_info_and_prepare_parted_commands( $MASTER_SCRIPT,
> > > + $image_dir,
> > > +
>$auto_install_script_conf);
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}CREATE_FILESYSTEMS${delim}\s*$/) {
> > > + _write_out_mkfs_commands( $MASTER_SCRIPT,
> > > + $image_dir,
> > > + $auto_install_script_conf );
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}GENERATE_FSTAB${delim}\s*$/) {
> > > + _write_out_new_fstab_file( $MASTER_SCRIPT,
> > > + $image_dir,
> > > + $auto_install_script_conf );
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}NO_LISTING${delim}\s*$/) {
> > > + if ($no_listing) { print $MASTER_SCRIPT "NO_LISTING=yes\n"; }
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}SYSTEMCONFIGURATOR${delim}\s*$/) {
> > > + write_sc_command($MASTER_SCRIPT, $ip_assignment_method);
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}UMOUNT_FILESYSTEMS${delim}\s*$/) {
> > > + _write_out_umount_commands( $MASTER_SCRIPT,
> > > + $image_dir,
> > > + $auto_install_script_conf );
> > > + last SWITCH;
> > > + }
> > > + if (/^\s*${delim}POSTINSTALL${delim}\s*/) {
> > > +
> > > + if ($post_install eq "beep") {
> > > + print $MASTER_SCRIPT $beep_code;
> > > + } elsif ($post_install eq "reboot") {
> > > + #reboot stuff
> > > + print $MASTER_SCRIPT "# reboot the autoinstall client\n";
> > > + print $MASTER_SCRIPT "shutdown -r now\n";
> > > + } elsif ($post_install eq "shutdown") {
> > > + #shutdown stuff
> > > + print $MASTER_SCRIPT "# shutdown the autoinstall client\n";
> > > + print $MASTER_SCRIPT "shutdown -h now\n";
> > > + print $MASTER_SCRIPT "\n";
> > > + }
> > > + last SWITCH;
> > > + }
> > > + ### END end of autoinstall options ###
> > > + print $MASTER_SCRIPT $_;
> > > + }
> > > }
> > > + close($TEMPLATE);
> > >
> > > - $rsync_opts .= " --exclude=lost+found/ --numeric-ids";
> > > -
> > > - ### BEGIN pull the image down ###
> > > - print MASTER_SCRIPT qq(# Filler up!\n);
> > > - print MASTER_SCRIPT qq(if [ ! -z \$PORTBASE ]; then \n);
> > > - print MASTER_SCRIPT qq(# Use multicast \n);
> > > - print MASTER_SCRIPT qq( mcast_group+2 \n);
> > > - $cmd = qq(udp-receiver --pipe 'tar -x -C /a' --portbase \${PORTBASE});
> > > - print MASTER_SCRIPT qq( echo "$cmd" \n);
> > > - print MASTER_SCRIPT qq( $cmd || shellout \n);
> > > - print MASTER_SCRIPT qq( \n);
> > > - print MASTER_SCRIPT qq(else \n);
> > > - print MASTER_SCRIPT qq( # Use rsync \n);
> > > - print MASTER_SCRIPT qq( echo "rsync $rsync_opts
>\${IMAGESERVER}::\${IMAGENAME}/ /a/" \n);
> > > - print MASTER_SCRIPT qq( rsync $rsync_opts
>\${IMAGESERVER}::\${IMAGENAME}/ /a/ || shellout \n);
> > > - print MASTER_SCRIPT qq( \n);
> > > - print MASTER_SCRIPT qq(fi \n);
> > > - ### END pull the image down ###
> > > -
> > > - if ($no_listing) {
> > > - print MASTER_SCRIPT '(kill $pid && shellout)' . "\n";
> > > - print MASTER_SCRIPT 'kill $pid' . "\n";
> > > - print MASTER_SCRIPT 'echo "done."' . "\n";
> > > - }
> > > -
> > > - ### BEGIN graffiti ###
> > > - print MASTER_SCRIPT "# Leave notice of which image is installed on the
>client\n";
> > > - print MASTER_SCRIPT "echo \$IMAGENAME >
>/a/etc/systemimager/IMAGE_LAST_SYNCED_TO || shellout\n";
> > > - ### END graffiti ###
> > > -
> > > - _write_out_new_fstab_file( $image_dir, $auto_install_script_conf );
> > > -
> > > ### BEGIN overrides stuff ###
> > > # Create default overrides directory. -BEF-
> > > #
> > > @@ -1419,134 +1328,7 @@ sub create_autoinstall_script{
> > > mkdir("$dir", 0755) or die "FATAL: Can't make directory $dir\n";
> > > }
> > >
> > > - ### BEGIN overrides ###
> > > - print MASTER_SCRIPT q(### BEGIN overrides ###) . qq(\n);
> > > - print MASTER_SCRIPT q(if [ ! -z $PORTBASE ]; then) . qq(\n);
> > > - print MASTER_SCRIPT q( # Use multicast) . qq(\n);
> > > - print MASTER_SCRIPT q( #) . qq(\n);
> > > - print MASTER_SCRIPT q( # A single cast will catch any and all override
>directories at once.) . qq(\n);
> > > - print MASTER_SCRIPT q( #) . qq(\n);
> > > - print MASTER_SCRIPT q( mcast_group+2) . qq(\n);
> > > - $cmd = qq(udp-receiver --pipe 'tar -x -C /a' --portbase \${PORTBASE});
> > > - print MASTER_SCRIPT qq( echo "$cmd") . qq(\n);
> > > - print MASTER_SCRIPT qq( $cmd || shellout) . qq(\n);
> > > - print MASTER_SCRIPT q( ) . qq(\n);
> > > - print MASTER_SCRIPT q(else) . qq(\n);
> > > - print MASTER_SCRIPT q( # Use rsync) . qq(\n);
> > > - print MASTER_SCRIPT q( for OVERRIDE in $OVERRIDES) . qq(\n);
> > > - print MASTER_SCRIPT q( do) . qq(\n);
> > > - print MASTER_SCRIPT q( echo "rsync -av --numeric-ids
>$IMAGESERVER::overrides/$OVERRIDE/ /a/") . qq(\n);
> > > - print MASTER_SCRIPT q( rsync -av --numeric-ids
>$IMAGESERVER::overrides/$OVERRIDE/ /a/ || echo "Override directory $OVERRIDE doesn't
>seem to exist, but that may be OK.") . qq(\n);
> > > - print MASTER_SCRIPT q( done) . qq(\n);
> > > - print MASTER_SCRIPT q(fi) . qq(\n);
> > > - print MASTER_SCRIPT q(### END overrides ###) . qq(\n);
> > > - ### END overrides ###
> > > -
> > > - print MASTER_SCRIPT qq(\n\n);
> > > -
> > > - print MASTER_SCRIPT
>qq(##################################################################\n);
> > > - print MASTER_SCRIPT qq(#\n);
> > > - print MASTER_SCRIPT qq(# Uncomment the line below to leave your hostname
>blank.\n);
> > > - print MASTER_SCRIPT qq(# Certain distributions use this as an indication to
>take on the\n);
> > > - print MASTER_SCRIPT qq(# hostname provided by a DHCP server. The default
>is to have\n);
> > > - print MASTER_SCRIPT qq(# SystemConfigurator assign your clients the
>hostname that\n);
> > > - print MASTER_SCRIPT qq(# corresponds to the IP address the use during the
>install.\n);
> > > - print MASTER_SCRIPT qq(# (If you used to use static_dhcp, is your man.)\n);
> > > - print MASTER_SCRIPT qq(#\n);
> > > - print MASTER_SCRIPT qq(#HOSTNAME=""\n);
> > > -
> > > - print MASTER_SCRIPT qq(\n\n);
> > > -
> > > - ### BEGIN System Configurator setup ###
> > > - print MASTER_SCRIPT "### BEGIN systemconfigurator ###\n";
> > > - # System Configurator for static IP
> > > - if ($ip_assignment_method eq "static") {
> > > - print MASTER_SCRIPT <<'EOF';
> > > -# Configure the client's hardware, network interface, and boot loader.
> > > -chroot /a/ systemconfigurator --configsi
>--excludesto=/etc/systemimager/systemconfig.local.exclude --stdin <<EOL || shellout
> > > -
> > > -[NETWORK]
> > > -HOSTNAME = $HOSTNAME
> > > -DOMAINNAME = $DOMAINNAME
> > > -GATEWAY = $GATEWAY
> > > -
> > > -[INTERFACE0]
> > > -DEVICE = eth0
> > > -TYPE = static
> > > -IPADDR = $IPADDR
> > > -NETMASK = $NETMASK
> > > -EOL
> > > -EOF
> > > -
> > > - } elsif ($ip_assignment_method eq "replicant") {
> > > - print MASTER_SCRIPT << 'EOF';
> > > -# Configure the client's boot loader.
> > > -chroot /a/ systemconfigurator --runboot || shellout
> > > -EOF
> > > -
> > > - } else { # aka elsif ($ip_assignment_method eq "dhcp")
> > > - print MASTER_SCRIPT <<'EOF';
> > > -# Configure the client's hardware, network interface, and boot loader.
> > > -chroot /a/ systemconfigurator --configsi --stdin <<EOL || shellout
> > > -
> > > -[NETWORK]
> > > -HOSTNAME = $HOSTNAME
> > > -DOMAINNAME = $DOMAINNAME
> > > -
> > > -[INTERFACE0]
> > > -DEVICE = eth0
> > > -TYPE = dhcp
> > > -EOL
> > > -EOF
> > > -
> > > - } ### END System Configurator setup ###
> > > - print MASTER_SCRIPT "### END systemconfigurator ###\n";
> > > -
> > > - print MASTER_SCRIPT qq(\n\n);
> > > -
> > > - _write_out_umount_commands( $image_dir, $auto_install_script_conf );
> > > -
> > > - print MASTER_SCRIPT qq(# Tell the image server we're done.\n);
> > > - print MASTER_SCRIPT qq(rsync \$IMAGESERVER::scripts/imaging_complete >
>/dev/null 2>&1\n);
> > > -
> > > - print MASTER_SCRIPT "\n";
> > > -
> > > - print MASTER_SCRIPT "# Take network interface down\n";
> > > - print MASTER_SCRIPT "ifconfig eth0 down || shellout\n";
> > > - print MASTER_SCRIPT "\n";
> > > -
> > > - if ($post_install eq "beep") {
> > > - print MASTER_SCRIPT << 'EOF';
> > > -# Cause the system to make noise and display an "I'm done." message
> > > -ralph="sick"
> > > -count="1"
> > > -while [ $ralph="sick" ]
> > > -do
> > > - echo -n -e "\\a"
> > > - [ $count -lt 60 ] && echo "I've been done for $count seconds. Reboot me
>already!"
> > > - [ $(($count / 60 * 60)) = $count ] && echo "I've been done for $(($count /
>60)) minutes now. Reboot me already!"
> > > - sleep 1
> > > - count=$(($count + 1))
> > > -done
> > > -
> > > -
> > > -EOF
> > > -
> > > -
> > > - } elsif ($post_install eq "reboot") {
> > > - #reboot stuff
> > > - print MASTER_SCRIPT "# reboot the autoinstall client\n";
> > > - print MASTER_SCRIPT "shutdown -r now\n";
> > > - print MASTER_SCRIPT "\n";
> > > - } elsif ($post_install eq "shutdown") {
> > > - #shutdown stuff
> > > - print MASTER_SCRIPT "# shutdown the autoinstall client\n";
> > > - print MASTER_SCRIPT "shutdown -h now\n";
> > > - print MASTER_SCRIPT "\n";
> > > - }
> > > - ### END end of autoinstall options ###
> > > -
> > > - close(MASTER_SCRIPT);
> > > + close($MASTER_SCRIPT);
> > > } # sub create_autoinstall_script
> > >
> > >
> >
> > > #!/bin/sh
> > >
> > > #
> > > # "SystemImager"
> > > #
> > > # Copyright (C) 1999-2001 Brian Elliott Finley
><[EMAIL PROTECTED]>
> > > # Copyright (C) 2002 Bald Guy Software <[EMAIL PROTECTED]>
> > > #
> > > ##VERSION_INFO##
> > >
> > > PATH=/sbin:/bin:/usr/bin:/usr/sbin:/tmp
> > > ARCH=`uname -m \
> > > | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/`
> > >
> > > ##NO_LISTING##
> > > if [ -z $NO_LISTING ]; then
> > > VERBOSE_OPT="v"
> > > else
> > > VERBOSE_OPT=""
> > > fi
> > >
> > > shellout() {
> > > exec cat /etc/issue ; exit 1
> > > }
> > >
> > > mcast_group+2() {
> > > PORTBASE=$(echo "scale=3; ($PORTBASE + 2)" | bc)
> > > }
> > >
> > > # Pull in variables left behind by the linuxrc script.
> > > # This information is passed from the linuxrc script on the autoinstall media
> > > # via /tmp/variables.txt. Apparently the shell we use in BOEL is not
> > > # intelligent enough to take a "set -a" parameter.
> > > #
> > > . /tmp/variables.txt || shellout
> > >
> > > [ -z $IMAGENAME ] && IMAGENAME=longs-rhas
> > > [ -z $OVERRIDES ] && OVERRIDES="longs-rhas"
> > >
> > > ### BEGIN Check to be sure this not run from a working machine ###
> > > # Test for mounted SCSI or IDE disks
> > > mount | grep [hs]d[a-z][1-9] > /dev/null 2>&1
> > > [ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
> > >
> > > # Test for mounted software RAID devices
> > > mount | grep md[0-9] > /dev/null 2>&1
> > > [ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
> > >
> > > # Test for mounted hardware RAID disks
> > > mount | grep c[0-9]+d[0-9]+p > /dev/null 2>&1
> > > [ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
> > > ### END Check to be sure this not run from a working machine ###
> > >
> > >
> > > ### BEGIN Stop RAID devices before partitioning begins ###
> > > # Q1) Why did they get started in the first place?
> > > # A1) So we can pull a local.cfg file off a root mounted software RAID system.
> > > # They may not be started on your system -- they would only be started if
> > > # you did the stuff in Q3 below.
> > > #
> > > # Q2) Why didn't my local.cfg on my root mounted software RAID work for me
> > > # with the standard kernel flavour?
> > > # A2) The standard kernel flavour uses modules for the software RAID drivers --
> > > # therefore, software RAID is not available at the point in the boot process
> > > # where BOEL needs to read the local.cfg file. They are only pulled over
> > > # when this script is run, which is, of course, only runnable if it was
> > > # pulled over the network using the settings that you would have wanted it
> > > # to get from the local.cfg file, which it couldn't. Right?
> > > #
> > > # Q3) Whatever. So how do I make it work with a local.cfg file on my root
> > > # mounted software RAID?
> > > # A3) Compile an autoinstall kernel with software RAID, and any other drivers
> > > # you might need built in (filesystem, SCSI drivers, etc.).
> > > #
> > > # Find running raid devices
> > > if [ -f /proc/mdstat ]; then
> > > RAID_DEVICES=` cat /proc/mdstat | grep ^md | sed 's/ .*$//g' `
> > >
> > > # raidstop will not run unless a raidtab file exists
> > > echo "" >> /etc/raidtab || shellout
> > >
> > > # turn dem pesky raid devices off!
> > > for RAID_DEVICE in ${RAID_DEVICES}
> > > do
> > > DEV="/dev/${RAID_DEVICE}"
> > > # we don't do a shellout here because, well I forgot why, but we don't.
> > > echo "raidstop ${DEV}" && raidstop ${DEV}
> > > done
> > > fi
> > > ### END Stop RAID devices before partitioning begins ###
> > >
> > > ##PARTITION_DISKS##
> > >
> > > echo "Load additional filesystem drivers."
> > > modprobe reiserfs
> > > modprobe ext2
> > > modprobe ext3
> > > modprobe jfs
> > > modprobe xfs
> > >
> > > ### BEGIN swap and filesystem creation commands ###
> > > ##CREATE_FILESYSTEMS##
> > > ### END swap and filesystem creation commands ###
> > >
> > > ### BEGIN mount proc in image for tools like System Configurator ###
> > > echo "mkdir -p /a/proc || shellout"
> > > mkdir -p /a/proc || shellout
> > > echo "mount proc /a/proc -t proc -o defaults || shellout"
> > > mount proc /a/proc -t proc -o defaults || shellout
> > > ### END mount proc in image for tools like System Configurator ###
> > >
> > > if [ $NO_LISTING ]; then
> > > echo -n "Quietly installing image...|"
> > > { while :; do
> > > echo -ne "\b/"; sleep 1;
> > > echo -ne "\b-"; sleep 1;
> > > echo -ne "\b\\"; sleep 1;
> > > echo -ne "\b|"; sleep 1;
> > > done
> > > }&
> > > pid=$!
> > > fi
> > >
> > > # Filler up!
> > > if [ ! -z $PORTBASE ]; then
> > > # Use multicast
> > > mcast_group+2
> > > echo "udp-receiver --pipe 'tar -x${VERBOSE_OPT} -C /a' --portbase
>${PORTBASE}"
> > > udp-receiver --pipe 'tar -x${VERBOSE_OPT} -C /a' --portbase ${PORTBASE} ||
>shellout
> > >
> > > else
> > > # Use rsync
> > > echo "rsync -a${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
>${IMAGESERVER}::${IMAGENAME}/ /a/"
> > > rsync -a${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
>${IMAGESERVER}::${IMAGENAME}/ /a/ || shellout
> > >
> > > fi
> > >
> > > if [ $NO_LISTING ]; then
> > > kill $pid
> > > echo "done."
> > > fi
> > >
> > > # Leave notice of which image is installed on the client
> > > echo $IMAGENAME > /a/etc/systemimager/IMAGE_LAST_SYNCED_TO || shellout
> > >
> > >
> > > ### BEGIN generate new fstab file from autoinstallscript.conf ###
> > > ##GENERATE_FSTAB##
> > > ### END generate new fstab file from autoinstallscript.conf ###
> > >
> > >
> > > ### BEGIN overrides ###
> > > if [ ! -z $PORTBASE ]; then
> > > # Use multicast
> > > #
> > > # A single cast will catch any and all override directories at once.
> > > #
> > > mcast_group+2
> > > echo "udp-receiver --pipe 'tar -x -C /a' --portbase ${PORTBASE}"
> > > udp-receiver --pipe 'tar -x -C /a' --portbase ${PORTBASE} || shellout
> > >
> > > else
> > > # Use rsync
> > > for OVERRIDE in $OVERRIDES
> > > do
> > > echo "rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/"
> > > rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/ || echo
>"Override directory $OVERRIDE doesn't seem to exist, but that may be OK."
> > > done
> > > fi
> > > ### END overrides ###
> > >
> > >
> > > ##################################################################
> > > #
> > > # Uncomment the line below to leave your hostname blank.
> > > # Certain distributions use this as an indication to take on the
> > > # hostname provided by a DHCP server. The default is to have
> > > # SystemConfigurator assign your clients the hostname that
> > > # corresponds to the IP address the use during the install.
> > > # (If you used to use static_dhcp, is your man.)
> > > #
> > > #HOSTNAME=""
> > >
> > >
> > > ### BEGIN systemconfigurator ###
> > > # Configure the client's hardware, network interface, and boot loader.
> > > ##SYSTEMCONFIGURATOR##
> > > ### END systemconfigurator ###
> > >
> > >
> > > ### BEGIN Unmount filesystems ###
> > > ##UMOUNT_FILESYSTEMS##
> > > ### END Unmount filesystems ###
> > >
> > >
> > > # Tell the image server we're done.
> > > rsync $IMAGESERVER::scripts/imaging_complete > /dev/null 2>&1
> > >
> > > # Take network interface down
> > > ifconfig eth0 down || shellout
> > >
> > > ##POSTINSTALL##
> >
> >
> > --
> > ---------------------------------------------------
> > Brian Elliott Finley http://baldguysoftware.com/
> > phone: 630.803.8183 http://systemimager.org/
> > ---------------------------------------------------
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Sisuite-devel mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/sisuite-devel
> >
--
---------------------------------------------------
Brian Elliott Finley http://baldguysoftware.com/
phone: 630.803.8183 http://systemimager.org/
---------------------------------------------------
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Sisuite-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/sisuite-devel