On Wed, 24 Jan 2007, Andrea Righi wrote:

> Ted Arden wrote:
> > then we went into the .master script and started changing
> > the last partition size to smaller and smaller increments
> > until we found one that worked.  basically i have a couple
> > of gigs of unused space on my array, but at least it works.
>
> maybe (but I'm not sure) it's because parted in your golden client uses
> the powers of 10 measures for MB, GB etc by default while parted in your
> boel_binaries uses powers of 2... could you post your
> autoinstallscript.conf and your master script? anyway you're using 3.6.3
> that is quite old and contains some bugs, fixed in recent releases. I
> hope soon we'll be able to release a new stable version to obviate this
> kind of problems...

we actually upgraded to 3.7.5 in hopes that it was
a version issue.  we also thought it was a 'last partition'
issue.  so we attempetd a single partition deployment
of the image with the same 'out of memory' failures as
with the 9 partitions.  we went with 3.6.3 as it was
listed as stable.

we have also discovered that the size of the last partition
needs to be modified regularly as the out of memory error
occurs not just at a specific parition size, but certain
sizes will work once, then not again, or bigger sizes
will work where others will not.  we had to remove the
end of disk partitioning regardless and define an end
geometry for the last partition.  we are losing roughly
~10G out of our array because of this.

> > the only problem is that we have found something that
> > kind of works, and re-running si_mkautoinstallscript will
> > kill the mods i already made to the master (i think) script.
>
> ...save your custom script before! ;-)

HAHAHAHHA.. always a good idea.
#!/bin/sh
#
#   "SystemImager"
#
#   $Id: autoinstallscript.template 3757 2006-09-28 08:54:18Z arighi $
#    vi:set filetype=sh:
#
#   Copyright (C) 1999-2006 Brian Elliott Finley
#
#   28.07.2005 Erich Focht : SCSI device detection and generation of
#                            /a/etc/systemconfig/hardware.lst
#
#   David N. Lombard : Disks enumeration and disk editing
#

# This master autoinstall script was created with SystemImager v3.7.5

# 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

# Load functions and other variables
. /etc/init.d/functions

get_arch

NO_LISTING=yes
if [ -z $NO_LISTING ]; then
    VERBOSE_OPT="v"
else
    VERBOSE_OPT=""
fi

[ -z $IMAGENAME ] && IMAGENAME=genv2test1
[ -z $OVERRIDES ] && OVERRIDES="genv2test1"

### 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 ] &&  logmsg 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 ] &&  logmsg 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 ] &&  logmsg Sorry.  Must not run on a working machine... && shellout
### END Check to be sure this not run from a working machine ###


################################################################################
#
#   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.).
#
if [ -f /proc/mdstat ]; then
  RAID_DEVICES=` cat /proc/mdstat | grep ^md | sed 's/ .*$//g' `

  # Turn dem pesky raid devices off!
  for RAID_DEVICE in ${RAID_DEVICES}
  do
    DEV="/dev/${RAID_DEVICE}"
    logmsg "mdadm --manage ${DEV} --stop"
    mdadm --manage ${DEV} --stop
  done
fi
#
################################################################################
# BEGIN disk enumeration
#
# Note the kludgey way to get /dev/sd* and /dev/*/c*d* to sort properly...
#
# Parse the correct file depending by the kernel release -AR-
kernel=`uname -r | sed "s/^\(2\.[64]\).*/\1/"`
if [ $kernel = "2.4" ]; then
    diskfile=/proc/partitions
else
    diskfile=/proc/diskstats
fi 

DISKORDER=

[ -z $DISKORDER ] || {
  logmsg enumerate_disks
  order=`echo "$DISKORDER" | sed 's/ /,/g' | sed s/,,*/,/g | sed s/^,//`
  DISKS=0
  cdroms=`cat /proc/sys/dev/cdrom/info 2>/dev/null | sed -ne "s/^drive 
name:[[:space:]]*//p"`
  while : ; do
    [ -z $order ] && break
    type=`expr $order : '\([^,]*\),' \| $order`
    case $type in
    cciss | ida | rd )
      for dev in `cat $diskfile | sed -ne "s/.*\($type\\/c[0-9]d[0-9]\).*/\1/p" 
| sort -u` ; do
        logmsg " $dev"
        eval DISK$DISKS=/dev/${dev}
        DISKS=`expr $DISKS + 1`
      done
      ;;
    hd | sd )
      for dev in `cat $diskfile | sed -ne "s/.*\($type[a-z]\+\).*/\1/p" | sort 
-u` ; do
        skip=0
        for cdrom in $cdroms; do
            if [ "$dev" = "$cdrom" ]; then
                skip=1
                break
            fi
        done
        if [ $skip -eq 0 ]; then
            logmsg " $dev"
            eval DISK$DISKS=/dev/${dev}
            DISKS=`expr $DISKS + 1`
        fi
      done
      ;;
    * )
      logmsg "type='$type'"
      shellout
      ;;
    esac
    order=`expr $order : '[^,]*,\(.*\)'`
  done
  logmsg DISKS=$DISKS
  [ $DISKS -eq 0 ] && {
    beep
    beep
    logmsg ""
    logmsg "NO DISK DEVICE FILES WERE FOUND.  THIS USUALLY MEANS THE KERNEL DID 
NOT"
    logmsg "RECOGNIZE ANY OF THE ATTACHED DISKS."
    logmsg ""
    logmsg "The kernel boot messages, which preceded this, may indicate why."
    logmsg ""
    logmsg "Reverting to disk configuration specified by image master script."
    DISKORDER=
    logmsg ""
  }
  echo
  beep
}
#
# END disk enumeration
################################################################################

if [ -z $DISKORDER ] ; then
  DISK0=/dev/sda
elif [ -z $DISK0 ] ; then
  echo "Undefined: DISK0"
  shellout
fi
### BEGIN partition $DISK0 ###
logmsg "Partitioning $DISK0..."
logmsg "Old partition table for $DISK0:"
parted -s -- $DISK0 print

# Wipe the MBR (Master Boot Record) clean.
logmsg "dd if=/dev/zero of=$DISK0 bs=512 count=1 || shellout"
dd if=/dev/zero of=$DISK0 bs=512 count=1 || shellout

# Re-read the disk label.
logmsg "blockdev --rereadpt $DISK0"
blockdev --rereadpt $DISK0

# Create disk label.  This ensures that all remnants of the old label, whatever
# type it was, are removed and that we're starting with a clean label.
logmsg "parted -s -- $DISK0 mklabel msdos || shellout"
parted -s -- $DISK0 mklabel msdos || shellout

# Get the size of the destination disk so that we can make the partitions fit 
properly.
DISK_SIZE=`parted -s $DISK0 unit MB print | grep 'Disk geometry for' | sed 
's/^.*-//g' | sed 's/\..*$//' | sed 's/MB//' `
[ -z $DISK_SIZE ] && shellout
if [ "$ARCH" = "alpha" ]; then
    END_OF_LAST_PRIMARY=1
else
    END_OF_LAST_PRIMARY=0
fi


logmsg "Creating partition ${DISK0}1."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 101)" | bc)
logmsg "parted -s -- $DISK0 mkpart primary $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart primary $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB

logmsg "Creating partition ${DISK0}2."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 2056)" | bc)
logmsg "parted -s -- $DISK0 mkpart primary linux-swap $START_MB $END_MB || 
shellout"
parted -s -- $DISK0 mkpart primary linux-swap $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB

logmsg "Creating partition ${DISK0}3."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 8197)" | bc)
logmsg "parted -s -- $DISK0 mkpart primary $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart primary $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB

logmsg "Creating partition ${DISK0}4."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(( $DISK_SIZE - 0 ))
logmsg "parted -s -- $DISK0 mkpart extended $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart extended $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
END_OF_LAST_LOGICAL=$START_MB
logmsg parted -s -- $DISK0 set 4 lba on || shellout
parted -s -- $DISK0 set 4 lba on || shellout

logmsg "Creating partition ${DISK0}5."
START_MB=$END_OF_LAST_LOGICAL
END_MB=$(echo "scale=3; ($START_MB + 4102)" | bc)
logmsg "parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout
END_OF_LAST_LOGICAL=$END_MB

logmsg "Creating partition ${DISK0}6."
START_MB=$END_OF_LAST_LOGICAL
END_MB=$(echo "scale=3; ($START_MB + 10245)" | bc)
logmsg "parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout
END_OF_LAST_LOGICAL=$END_MB

logmsg "Creating partition ${DISK0}7."
START_MB=$END_OF_LAST_LOGICAL
END_MB=$(echo "scale=3; ($START_MB + 40963)" | bc)
logmsg "parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout
END_OF_LAST_LOGICAL=$END_MB

logmsg "Creating partition ${DISK0}8."
START_MB=$END_OF_LAST_LOGICAL
END_MB=$(echo "scale=3; ($START_MB + 20489)" | bc)
logmsg "parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout
END_OF_LAST_LOGICAL=$END_MB

logmsg "Creating partition ${DISK0}9."
START_MB=$END_OF_LAST_LOGICAL
END_MB=$(( $DISK_SIZE - 0 ))
logmsg "parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout"
parted -s -- $DISK0 mkpart logical $START_MB $END_MB || shellout
END_OF_LAST_LOGICAL=$END_MB

logmsg "New partition table for $DISK0:"
logmsg "parted -s -- $DISK0 print"
parted -s -- $DISK0 print
### END partition $DISK0 ###



### BEGIN software-RAID initialization commands -AR- ###
logmsg "Load software RAID modules."
modprobe linear
modprobe raid0
modprobe raid1
modprobe raid5
modprobe raid6
modprobe raid10
### END software-RAID initialization commands ###

logmsg "Load device mapper driver (for LVM)."
modprobe dm-mod

### BEGIN LVM initialization commands -AR- ###
### END LVM initialization commands ###

### BEGIN LVM groups creation commands -AR- ###
### END LVM groups creation commands ###

### BEGIN LVM volumes creation commands -AR- ###
### END LVM volumes creation commands ###

logmsg "Load additional filesystem drivers."
modprobe ext2
modprobe ext3
modprobe fat
modprobe jfs
modprobe reiserfs
modprobe vfat
modprobe xfs

### BEGIN swap and filesystem creation commands ###
logmsg "mke2fs -j ${DISK0}3 || shellout"
mke2fs -j ${DISK0}3 || shellout
logmsg "mkdir -p /a/ || shellout"
mkdir -p /a/ || shellout
logmsg "mount ${DISK0}3 /a/ -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}3 /a/ -t ext3 -o acl,user_xattr || shellout

logmsg "mke2fs -j ${DISK0}1 || shellout"
mke2fs -j ${DISK0}1 || shellout
logmsg "mkdir -p /a/boot || shellout"
mkdir -p /a/boot || shellout
logmsg "mount ${DISK0}1 /a/boot -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}1 /a/boot -t ext3 -o acl,user_xattr || shellout

logmsg "mke2fs -j ${DISK0}7 || shellout"
mke2fs -j ${DISK0}7 || shellout
logmsg "mkdir -p /a/home || shellout"
mkdir -p /a/home || shellout
logmsg "mount ${DISK0}7 /a/home -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}7 /a/home -t ext3 -o acl,user_xattr || shellout

logmsg "mke2fs -j ${DISK0}9 || shellout"
mke2fs -j ${DISK0}9 || shellout
logmsg "mkdir -p /a/opt || shellout"
mkdir -p /a/opt || shellout
logmsg "mount ${DISK0}9 /a/opt -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}9 /a/opt -t ext3 -o acl,user_xattr || shellout

logmsg "mke2fs -j ${DISK0}6 || shellout"
mke2fs -j ${DISK0}6 || shellout
logmsg "mkdir -p /a/tftpboot || shellout"
mkdir -p /a/tftpboot || shellout
logmsg "mount ${DISK0}6 /a/tftpboot -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}6 /a/tftpboot -t ext3 -o acl,user_xattr || shellout

logmsg "mke2fs -j ${DISK0}8 || shellout"
mke2fs -j ${DISK0}8 || shellout
logmsg "mkdir -p /a/usr || shellout"
mkdir -p /a/usr || shellout
logmsg "mount ${DISK0}8 /a/usr -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}8 /a/usr -t ext3 -o acl,user_xattr || shellout

logmsg "mke2fs -j ${DISK0}5 || shellout"
mke2fs -j ${DISK0}5 || shellout
logmsg "mkdir -p /a/var || shellout"
mkdir -p /a/var || shellout
logmsg "mount ${DISK0}5 /a/var -t ext3 -o acl,user_xattr || shellout"
mount ${DISK0}5 /a/var -t ext3 -o acl,user_xattr || shellout

logmsg "mkswap -v1  ${DISK0}2 || shellout"
mkswap -v1  ${DISK0}2 || shellout
logmsg "swapon ${DISK0}2 || shellout"
swapon ${DISK0}2 || shellout

### END swap and filesystem creation commands ###

### BEGIN mount proc in image for tools like System Configurator ###
logmsg "mkdir -p /a/proc || shellout"
mkdir -p /a/proc || shellout
logmsg "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 [ ! $kernel = "2.4" ]; then
### BEGIN mount sysfs in image for tools that might be run during chroot ###
logmsg "mkdir -p /a/sys || shellout"
mkdir -p /a/sys || shellout
logmsg "mount sysfs /a/sys -t sysfs -o defaults || shellout"
mount sysfs /a/sys -t sysfs -o defaults || shellout
### END mount sysfs in image for tools that might be run during chroot ###
fi

################################################################################
#
#   Lay the image down on the freshly formatted disk(s)
#
if [ ! -z $MONITOR_SERVER ]; then
    start_report_task
fi

if [ ! -z $FLAMETHROWER_DIRECTORY_PORTBASE ]; then 

    # Use multicast 
    MODULE_NAME="${IMAGENAME}"
    DIR=/a
    RETRY=7
    FLAMETHROWER_TARPIPE=y
    flamethrower_client
    if [ ! -z $MONITOR_SERVER ]; then
        stop_report_task 101
    fi
elif [ "x$BITTORRENT" = "xy" ]; then
    # Use BitTorrent
    if [ -f "${TORRENTS_DIR}/image-${IMAGENAME}.tar.gz.torrent" ]; then
        bittorrent_tarball="image-${IMAGENAME}.tar.gz"
        compress='z'
    elif [ -f "${TORRENTS_DIR}/image-${IMAGENAME}.tar.torrent" ]; then
        bittorrent_tarball="image-${IMAGENAME}.tar"
        compress=''
    else
        logmsg "error: cannot find a valid torrent file for the image 
${IMAGENAME}"
        shellout
    fi
    # Evaluate the staging directory
    if [ -z $BITTORRENT_STAGING ]; then
        logmsg bittorrent_autodetect_staging_dir
        BITTORRENT_STAGING=`bittorrent_autodetect_staging_dir 
${TORRENTS_DIR}/${bittorrent_tarball}.torrent`
        if [ -z $BITTORRENT_STAGING ]; then
            logmsg ""
            logmsg "error: cannot find a staging directory to save file: 
$bittorrent_tarball"
            logmsg "Try to increase the size of a partition (like /tmp) in your 
patitioning schema"
            logmsg "to fit the image into a staging directory."
            logmsg ""
            shellout
        fi
    fi
    # Download image from peers
    logmsg "Start downloading image using torrent ${bittorrent_tarball}.torrent"
    logmsg ""
    logmsg "--> INFO: remember to start 
/etc/init.d/systemimager-server-bittorrent on the image server!"
    logmsg ""
    bittorrent_get_file ${TORRENTS_DIR}/${bittorrent_tarball}.torrent 
${BITTORRENT_STAGING}
    if [ ! -z $MONITOR_SERVER ]; then
        stop_report_task 101
    fi
    # Extract image.
    logmsg "Extracting image from ${bittorrent_tarball} ..."
    (cd /a/ && tar -x${VERBOSE_OPT}${compress}Spf 
${BITTORRENT_STAGING}/${bittorrent_tarball} > /dev/console) || shellout

    # Stop BitTorrent client.
    bittorrent_stop
    rm -f ${BITTORRENT_STAGING}/${bittorrent_tarball}
    unset bittorrent_tarball
else 
    # Use rsync 
    if [ $NO_LISTING ]; then
        logmsg "Quietly installing image... "
        start_spinner
    fi
    if [ "${TMPFS_STAGING}" = "yes" ]; then 

        # Deposit image into tmpfs
        DIR=/tmp/tmpfs_staging
        logmsg
        logmsg "TMPFS_STAGING=${TMPFS_STAGING} -- Staging in ${DIR}"
        mkdir -p ${DIR}

        logmsg "rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids 
${IMAGESERVER}::${IMAGENAME}/ ${DIR}/" 
        rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --exclude=/proc/* 
--numeric-ids \
              ${IMAGESERVER}::${IMAGENAME}/ ${DIR}/ > /dev/console || shellout 

        if [ ! -z $MONITOR_SERVER ]; then
            stop_report_task 101
        fi

        # Move from staging in tmpfs to disk
        rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids ${DIR}/ 
/a/ > /dev/console || shellout
    else
        logmsg "rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ 
--exclude=/proc/* --numeric-ids ${IMAGESERVER}::${IMAGENAME}/ /a/" 
        rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --exclude=/proc/* 
--numeric-ids ${IMAGESERVER}::${IMAGENAME}/ /a/ > /dev/console || shellout 
        if [ ! -z $MONITOR_SERVER ]; then
            stop_report_task 101
        fi
    fi
fi 

beep

#
################################################################################


if [ $NO_LISTING ]; then
    stop_spinner
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 ###
cat <<'EOF' > /a/etc/fstab
/dev/sda3       /       ext3    acl,user_xattr  1       1
/dev/sda1       /boot   ext3    acl,user_xattr  1       2
/dev/sda7       /home   ext3    acl,user_xattr  1       2
/dev/sda9       /opt    ext3    acl,user_xattr  1       2
/dev/sda6       /tftpboot       ext3    acl,user_xattr  1       2
/dev/sda8       /usr    ext3    acl,user_xattr  1       2
/dev/sda5       /var    ext3    acl,user_xattr  1       2
/dev/sda2       swap    swap    pri=42  0       0
devpts  /dev/pts        devpts  mode=0620,gid=5 0       0
proc    /proc   proc    defaults        0       0
usbfs   /proc/bus/usb   usbfs   noauto  0       0
sysfs   /sys    sysfs   noauto  0       0
/dev/cdrom      /media/cdrom    subfs   
fs=cdfss,ro,procuid,nosuid,nodev,exec,iocharset=utf8    0       0
/dev/fd0        /media/floppy   subfs   fs=floppyfss,procuid,nodev,nosuid,sync  
0       0
EOF
### END generate new fstab file from autoinstallscript.conf ###

################################################################################
#
#   Process override directories
#
for OVERRIDE in $OVERRIDES
do
    if [ ! -z $FLAMETHROWER_DIRECTORY_PORTBASE ]; then
        # Use multicast
        MODULE_NAME="override_${OVERRIDE}"
        DIR=/a
        RETRY=7
        FLAMETHROWER_TARPIPE=y
        flamethrower_client
    elif [ "x$BITTORRENT" = "xy" ]; then
        # Use BitTorrent
        if [ -f "${TORRENTS_DIR}/override-${OVERRIDE}.tar.gz.torrent" ]; then
            bittorrent_tarball="override-${OVERRIDE}.tar.gz"
            compress='z'
        elif [ -f "${TORRENTS_DIR}/override-${OVERRIDE}.tar.torrent" ]; then
            bittorrent_tarball="override-${OVERRIDE}.tar"
            compress=''
        else
            bittorrent_tarball=""
            logmsg "warning: cannot find a valid torrent file for override 
${OVERRIDE}"
        fi
        # Evaluate the staging directory
        if [ ! -z $bittorrent_tarball ] && [ -z $BITTORRENT_STAGING ]; then
            logmsg bittorrent_autodetect_staging_dir
            BITTORRENT_STAGING=`bittorrent_autodetect_staging_dir 
${TORRENTS_DIR}/${bittorrent_tarball}.torrent`
            if [ -z $BITTORRENT_STAGING ]; then
                logmsg "warning: cannot find a staging directory to save file: 
$bittorrent_tarball"
                bittorrent_tarball=""
            fi
        fi
        if [ ! -z $bittorrent_tarball ]; then
            # Start downloading
            logmsg "Start downloading override using torrent 
${bittorrent_tarball}.torrent"
            logmsg ""
            logmsg "--> INFO: remember to start 
/etc/init.d/systemimager-server-bittorrent on the image server!"
            logmsg ""
            # Download override from peers
            bittorrent_get_file ${TORRENTS_DIR}/${bittorrent_tarball}.torrent 
${BITTORRENT_STAGING}
            # Extract override.
            logmsg "Extracting override from ${bittorrent_tarball} ..."
            (cd /a/ && tar -x${VERBOSE_OPT}${compress}Spf 
${BITTORRENT_STAGING}/${bittorrent_tarball} > /dev/console) || shellout
            # Stop BitTorrent client.
            bittorrent_stop
            rm -f ${BITTORRENT_STAGING}/${bittorrent_tarball}
        else
            # Use rsync
            logmsg "trying to download override ${OVERRIDE} with rsync..."
            logmsg "rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ 
/a/"
            rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/ > 
/dev/console || logmsg "Override directory $OVERRIDE doesn't seem to exist, but 
that may be OK."
        fi
        unset bittorrent_tarball
    else
        # Use rsync
        logmsg "rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/"
        rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/ > 
/dev/console || logmsg "Override directory $OVERRIDE doesn't seem to exist, but 
that may be OK."
    fi
done

beep

#
################################################################################

################################################################################
# BEGIN disk edits
#
[ -z $DISKORDER ] || {
  echo "Editing files for actual disk configuration..."
  echo " /dev/sda -> $DISK0"
  for file in /etc/fstab /etc/systemconfig/systemconfig.conf 
/boot/grub/menu.lst /etc/lilo.conf /etc/grub.conf; do
    [ -f /a/$file ] || continue
    echo " $file"
    cp /a/$file /a/$file.image
    cat /a/$file.image |
    sed s:/dev/sda:%DISK0%:g |
    sed s:%DISK0%:$DISK0:g |
    cat > /a/$file
  done
  echo
  beep
}
#
# END disk edits
################################################################################


##################################################################
#
# 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 the static_dhcp option, this is your man.)
#
#HOSTNAME=""


################################################################################
#
# mount /dev /a/dev -o bind if needed
#
#not needed for this image
#
################################################################################


################################################################################
#
#   Detect scsi hardware and include the device IDs into the hardware.lst
#   file used by systemconfigurator. Do nothing if the hardware.lst file
#   already exists (which is a sign that it has been already prepared).
#   Would be shorter if discover could return numerical device IDs...
#
if [ ! -f /a/etc/systemconfig/hardware.lst ]; then
   [ ! -d /a/etc/systemconfig ] && mkdir -p /a/etc/systemconfig
   SCSI_MODS=`discover -f "%m\n" scsi | grep -v ide-scsi | uniq`
   for MOD in $SCSI_MODS; do
      DEVID=`grep $MOD /proc/bus/pci/devices | cut -f 2 | sort | uniq`
      for MYDEV in $DEVID; do
         VENDOR=`echo $MYDEV | cut -b 1-4`
         MODEL=`echo $MYDEV | cut -b 5-8`
         echo "$VENDOR $MODEL scsi $MOD" >> /a/etc/systemconfig/hardware.lst
         echo "Added SCSI device $VENDOR:$MODEL using module $MOD to 
hardware.lst"
      done
   done
fi
#
################################################################################

################################################################################
#
#   System Configurator
#
# Configure the client's hardware, network interface, and boot loader.
#

# Create an /etc/mtab file with appropriate entries
cat /etc/mtab | grep -v '/dev/ram' | grep -v -E '^\/dev\s+\/a\/dev\s' | sed 
's,/a/*,/,g' | sort -u > /a/etc/mtab

[ -z $DEVICE ] && DEVICE=eth0
chroot /a/ systemconfigurator 
--excludesto=/etc/systemimager/systemconfig.local.exclude --configsi --stdin << 
EOL || shellout
[NETWORK]
HOSTNAME = $HOSTNAME
DOMAINNAME = $DOMAINNAME

[INTERFACE0]
DEVICE = eth0
TYPE = dhcp
EOL
#
################################################################################


################################################################################
#
#   Post Install Scripts
#
run_post_install_scripts
#
################################################################################

################################################################################
#
#   Save virtual console session in the imaged client
#
if [ ! -z $MONITOR_SERVER ]; then
    if [ "x$MONITOR_CONSOLE" = "xyes" ]; then 
        [ ! -d /a/root ] && mkdir -p /a/root
        cp -f /tmp/si_monitor.log /a/root/si_monitor.log
    fi
fi

#
################################################################################


################################################################################
#
#   Unmount filesystems
#
logmsg "umount /a/var || shellout"
umount /a/var || shellout

logmsg "umount /a/usr || shellout"
umount /a/usr || shellout

logmsg "umount /a/tftpboot || shellout"
umount /a/tftpboot || shellout

if [ ! $kernel = "2.4" ]; then
logmsg "umount /a/sys || shellout"
umount /a/sys || shellout
fi

logmsg "umount /a/proc || shellout"
umount /a/proc || shellout

logmsg "umount /a/opt || shellout"
umount /a/opt || shellout

logmsg "umount /a/home || shellout"
umount /a/home || shellout

logmsg "umount /a/boot || shellout"
umount /a/boot || shellout

logmsg "umount /a/ || shellout"
umount /a/ || shellout

#
################################################################################


################################################################################
#
#   Tell the image server we are done
#   
rsync $IMAGESERVER::scripts/imaging_complete > /dev/null 2>&1
logmsg "Imaging completed"
#
################################################################################

if [ ! -z $MONITOR_SERVER ]; then
    # Report the 'imaged' state to the monitor server.
    send_monitor_msg "status=100:speed=0"
    if [ "x$MONITOR_CONSOLE" = "xyes" ]; then 
        # Print some empty lines and sleep some seconds to give time to
        # the virtual console to get last messages.
        # XXX: this is a dirty solution, we should find a better way to
        # sync last messages... -AR-
        logmsg ""
        logmsg ""
        logmsg ""
        sleep 10
    fi
    # Report the post-install action.
    send_monitor_msg "status=103:speed=0"
fi


# Take network interface down
[ -z $DEVICE ] && DEVICE=eth0
ifconfig $DEVICE down || shellout

# Announce completion (even for non beep-incessantly --post-install options)
beep 3

beep_incessantly
<!--
  
  autoinstallscript.conf
  vi:set filetype=xml:
  
  This file contains partition information about the disks on your golden
  client.  It is stored here in a generic format that is used by your
  SystemImager server to create an autoinstall script for cloning this
  system.
  
  You can change the information in this file to affect how your target
  machines are installed.  See "man autoinstallscript.conf" for details.
  
-->

<config>

  <disk dev="/dev/sda" label_type="msdos" unit_of_measurement="MB">
    <!--
      This disk's output was brought to you by the partition tool "sfdisk",
      and by the numbers 4 and 5 and the letter Q.
    -->
    <part  num="1"  size="101"  p_type="primary"  p_name="-"  flags="-" />
    <part  num="2"  size="2056"  p_type="primary"  p_name="-"  flags="swap" />
    <part  num="3"  size="8197"  p_type="primary"  p_name="-"  flags="-" />
    <part  num="4"  size="*"  p_type="extended"  p_name="-"  flags="lba" />
    <part  num="5"  size="4102"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="6"  size="10245"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="7"  size="40963"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="8"  size="20489"  p_type="logical"  p_name="-"  flags="-" />
    <part  num="9"  size="*"  p_type="logical"  p_name="-"  flags="-" />
  </disk>


  <fsinfo  line="10" real_dev="/dev/sda3" mp="/"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="1" />
  <fsinfo  line="20" real_dev="/dev/sda1" mp="/boot"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="2" />
  <fsinfo  line="30" real_dev="/dev/sda7" mp="/home"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="2" />
  <fsinfo  line="40" real_dev="/dev/sda9" mp="/opt"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="2" />
  <fsinfo  line="50" real_dev="/dev/sda6" mp="/tftpboot"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="2" />
  <fsinfo  line="60" real_dev="/dev/sda8" mp="/usr"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="2" />
  <fsinfo  line="70" real_dev="/dev/sda5" mp="/var"  fs="ext3" 
options="acl,user_xattr" dump="1" pass="2" />
  <fsinfo  line="80" real_dev="/dev/sda2" mp="swap"  fs="swap" options="pri=42" 
dump="0" pass="0" />
  <fsinfo  line="90" real_dev="devpts" mp="/dev/pts"  fs="devpts" 
options="mode=0620,gid=5" dump="0" pass="0" />
  <fsinfo  line="100" real_dev="proc" mp="/proc"  fs="proc" options="defaults" 
dump="0" pass="0" />
  <fsinfo  line="110" real_dev="usbfs" mp="/proc/bus/usb"  fs="usbfs" 
options="noauto" dump="0" pass="0" />
  <fsinfo  line="120" real_dev="sysfs" mp="/sys"  fs="sysfs" options="noauto" 
dump="0" pass="0" />
  <fsinfo  line="130" real_dev="/dev/cdrom" mp="/media/cdrom"  fs="subfs" 
options="fs=cdfss,ro,procuid,nosuid,nodev,exec,iocharset=utf8" dump="0" 
pass="0" />
  <fsinfo  line="140" real_dev="/dev/fd0" mp="/media/floppy"  fs="subfs" 
options="fs=floppyfss,procuid,nodev,nosuid,sync" dump="0" pass="0" />

  <boel devstyle="static"/>

</config>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sisuite-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sisuite-users

Reply via email to