Commit 78814da7 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

More little changes for CMU widearea loading. Not done yet ...

parent db5f9c29
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# Copyright (c) 2000-2005, 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -20,10 +20,14 @@ my $DOSTYPE = "$BINDIR/dostype";
#
sub usage()
{
print("Usage: mkextrafs.pl [-f] [-s slice] <mountpoint>\n");
print("Usage: mkextrafs.pl [-f] [-s slice] [-r disk] <mountpoint>\n");
exit(-1);
}
my $optlist = "fs:";
my $optlist = "fs:r:cn";
my $diskopt;
my $checkit = 0;
my $forceit = 0;
my $noinit = 0;
#
# Yep, hardwired for now. Should be options or queried via TMCC.
......@@ -31,7 +35,6 @@ my $optlist = "fs:";
my $disk = "ad0";
my $slice = "4";
my $partition = "e";
my $forceit = 0;
sub mysystem($);
......@@ -62,6 +65,18 @@ if (defined($options{"f"})) {
if (defined($options{"s"})) {
$slice = $options{"s"};
}
if (defined($options{"c"})) {
$checkit = 1;
}
if (defined($options{"c"})) {
$checkit = 1;
}
if (defined($options{"r"})) {
$diskopt = $options{"r"};
}
if (defined($options{"n"})) {
$noinit = $options{"n"};
}
if (@ARGV != 1) {
usage();
}
......@@ -73,11 +88,16 @@ if (! -d $mountpoint) {
}
#
# XXX determine the disk based on the root fs
# XXX determine the disk based on the root fs if not provided.
#
my $rootdev = `df | egrep '/\$'`;
if ($rootdev =~ /^\/dev\/([a-z]+\d+)s[1-4][a-h]/) {
$disk = $1;
if (defined($diskopt)) {
$disk = $diskopt;
}
else {
my $rootdev = `df | egrep '/\$'`;
if ($rootdev =~ /^\/dev\/([a-z]+\d+)s[1-4][a-h]/) {
$disk = $1;
}
}
my $slicedev = "${disk}s${slice}";
......@@ -89,13 +109,13 @@ my $fsdevice = "/dev/${slicedev}${partition}";
#
if (!system("egrep -q -s '^${fsdevice}' /etc/fstab")) {
if ($checkit) {
exit(-1);
exit(0);
}
die("*** $0:\n".
" There is already an entry in /etc/fstab for $fsdevice\n");
}
elsif ($checkit) {
exit(0);
exit(1);
}
#
......@@ -138,6 +158,11 @@ if ($stype != 165) {
if (! -e "$DOSTYPE");
mysystem("$DOSTYPE -f /dev/$disk $slice 165");
}
elsif ($noinit) {
mysystem("mount $fsdevice $mountpoint");
mysystem("echo \"$fsdevice $mountpoint ufs rw 0 2\" >> /etc/fstab");
exit(0);
}
#
# Now create the disklabel
......@@ -191,6 +216,7 @@ mysystem("echo \"$fsdevice $mountpoint ufs rw 0 2\" >> /etc/fstab");
mysystem("mount $mountpoint");
mysystem("mkdir $mountpoint/local");
exit(0);
sub mysystem($)
{
......
......@@ -231,18 +231,6 @@ if [ x"$ADDRESS" != x ]; then
#
imagefile=`echo $ADDRESS | sed -e 's,^http[s]*://[^/]*/,,'`
imagefile="/images/$imagefile"
wget -nv -N -P /images "$ADDRESS"
wstat=$?
case $wstat in
0)
echo "wget succeeded getting the image"
;;
*)
echo "wget failed, status $wstat"
exit 1
;;
esac
elif [ x"$ispath" != x ]; then
ispath=1
......@@ -297,6 +285,31 @@ if [ x"$ADDRESS" != x ]; then
tweakmbr $DISK $MBR
fi
#
# If a remote node and we have a URL, make sure that we have a place
# to put it. Done after the MBR tweak of course. Then download the
$ URL.
#
if [ $isrem -eq 1 -a $isurl -eq 1 ]; then
$BINDIR/mkextrafs.pl -c -s 4 -r $DISK /images || {
$BINDIR/mkextrafs.pl -n -f -s 4 -r $DISK /images || {
echo "Could not create /images partition"
exit 1
}
}
wget -nv -N -P /images "$ADDRESS"
wstat=$?
case $wstat in
0)
echo "wget succeeded getting the image"
;;
*)
echo "wget failed, status $wstat"
exit 1
;;
esac
fi
#
# If not zeroing the disk and we are loading a full disk image
# we need to ensure that we at least invalidate any old superblocks
......@@ -316,8 +329,8 @@ if [ x"$ADDRESS" != x ]; then
$BINDIR/tmcc state RELOADING
if [ x"$imagefile" != x ]; then
echo "Running /usr/local/bin/imageunzip -o -O -W 32 $SLICE $ZFILL $imagefile /dev/$DISK"
/usr/local/bin/imageunzip -o -O -W 32 $SLICE $ZFILL $imagefile /dev/$DISK
echo "Running /usr/local/bin/imageunzip -o -O -W 32 $ZFILL $imagefile /dev/${DISK}s${PARTITION}"
/usr/local/bin/imageunzip -o -O -W 32 $ZFILL $imagefile /dev/${DISK}s${PARTITION}
else
echo "Running $BINDIR/frisbee $LOADIP $MEMARGS $ZFILL $SLICE $MCASTIF $MCASTADDR /dev/$DISK at `date`"
$BINDIR/frisbee $LOADIP $MEMARGS $ZFILL $SLICE $MCASTIF $MCASTADDR /dev/$DISK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment