Commit 8d80301e authored by Mike Hibler's avatar Mike Hibler

More work toward getting this working on subboss.

More work on the hierarchical configuration for subboss. When doing host-based
authentication, allow client to pass an explicit host (IP) to the mserver.
If the mserver is configured to allow it, that IP is used for authenticating
the request instead of the caller's IP. Add a default ("null") configuration
so the mserver can operate out-of-the-box with no config file. The goal of
these two changes is for an mserver instance with the default config and a
proxy option to serve the needs of a subboss node (i.e., so no explicit
configuration will be needed).
parent c5b7cceb
......@@ -190,7 +190,7 @@ if ($SCRATCHDIR) {
my @LOGFILES = ("$LOGDIR/bootinfo.log", "$LOGDIR/tmcd.log",
"$LOGDIR/capture.log", "$LOGDIR/dhcpd.log", "$LOGDIR/capserver.log",
"$LOGDIR/frisbeed.log", "$LOGDIR/proxydhcpd.log",
"$LOGDIR/frisbeed.log", "$LOGDIR/mfrisbeed.log", "$LOGDIR/proxydhcpd.log",
"$LOGDIR/stated.log", "$LOGDIR/osselect.log",
"$LOGDIR/tftpd.log", "$LOGDIR/sdcollectd.log", "$LOGDIR/genlastlog.log",
"$LOGDIR/sshxmlrpc.log", "$LOGDIR/plabgetfree.log", "$LOGDIR/xmlrpcbag.log",
......@@ -828,6 +828,7 @@ Phase "syslog", "Setting up syslog", sub {
"!tftpd", "*.*\t\t\t\t\t\t$LOGDIR/tftpd.log",
"!capserver", "*.*\t\t\t\t\t\t$LOGDIR/capserver.log",
"!frisbeed", "*.*\t\t\t\t\t\t$LOGDIR/frisbeed.log",
"!mfrisbeed", "*.*\t\t\t\t\t\t$LOGDIR/mfrisbeed.log",
"!pubsubd", "*.*\t\t\t\t\t\t$LOGDIR/pubsubd.log",
"!osselect", "*.*\t\t\t\t\t\t$LOGDIR/osselect.log",
"!genlastlog","*.*\t\t\t\t\t\t$LOGDIR/genlastlog.log",
......@@ -876,6 +877,7 @@ Phase "syslog", "Setting up syslog", sub {
"$LOGDIR/osselect.log 640 9 300 * Z",
"$LOGDIR/power.log 640 7 300 * Z",
"$LOGDIR/frisbeed.log 640 7 300 * Z",
"$LOGDIR/mfrisbeed.log 640 7 300 * Z",
"$LOGDIR/tftpd.log 640 7 200 * Z",
"$LOGDIR/dhcpd.log 640 7 200 * Z",
"$LOGDIR/bootinfo.log 640 7 200 * Z",
......
......@@ -33,6 +33,9 @@ endif
endif
endif
WITH_MSERVER_NULL = 1
WITH_MSERVER_EMULAB = 0
include $(OBJDIR)/Makeconf
all: frisbee frisbeed mfrisbeed
......@@ -63,11 +66,22 @@ SERVERFLAGS = $(CFLAGS)
SERVERLIBS = $(PTHREADLIBS)
SERVEROBJS = server.o $(SHAREDOBJS)
#
# Master server configuration
#
# Default master server config
MSERVERFLAGS = -DUSE_NULL_CONFIG $(CFLAGS) -I$(OBJDIR)
MSERVEROBJS = mserver.o $(SHAREDOBJS) config.o config_null.o
MSERVERLIBS =
ifeq ($(WITH_MSERVER_EMULAB),1)
# Emulab master server config
MYSQLCFLAGS = -I/usr/local/include
MYSQLLIBS = -L/usr/local/lib/mysql -lmysqlclient
MSERVERFLAGS = $(CFLAGS) $(MYSQLCFLAGS) -DUSE_EMULAB_CONFIG -I$(TESTBED_SRCDIR)/lib/libtb -I$(OBJDIR)
MSERVERLIBS = $(OBJDIR)/lib/libtb/libtb.a $(MYSQLLIBS)
MSERVEROBJS = mserver.o config.o config_emulab.o $(SHAREDOBJS)
MSERVERFLAGS += -DUSE_EMULAB_CONFIG $(MYSQLCFLAGS) -I$(TESTBED_SRCDIR)/lib/libtb
MSERVEROBJS += config_emulab.o
MSERVERLIBS += $(OBJDIR)/lib/libtb/libtb.a $(MYSQLLIBS)
endif
CFLAGS = -O2 -g -Wall -fno-builtin-log $(LDSTATIC) $(PTHREADCFLAGS) -DSTATS -DMASTER_SERVER
LDFLAGS = $(LDSTATIC)
......@@ -125,6 +139,8 @@ config.o: $(SRCDIR)/config.c configdefs.h log.h
$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/config.c
config_emulab.o: $(SRCDIR)/config_emulab.c configdefs.h log.h
$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/config_emulab.c
config_null.o: $(SRCDIR)/config_null.c configdefs.h log.h
$(CC) -c $(MSERVERFLAGS) $(SRCDIR)/config_null.c
log.o: $(SRCDIR)/log.c decls.h log.h
$(CC) $(CFLAGS) -DLOG_TESTBED=$(LOG_TESTBED) -c $(SRCDIR)/log.c
......
......@@ -45,15 +45,17 @@ config_init(int readit)
int rv;
#ifdef USE_EMULAB_CONFIG
extern struct config emulab_config;
myconfig = &emulab_config;
#else
extern struct config file_config;
myconfig = &file_config;
extern struct config *emulab_init();
if (myconfig == NULL)
myconfig = emulab_init();
#endif
#ifdef USE_NULL_CONFIG
extern struct config *null_init();
if (myconfig == NULL)
myconfig = null_init();
#endif
rv = myconfig->config_init();
if (rv)
return rv;
if (myconfig == NULL)
return -1;
if (readit) {
rv = myconfig->config_read();
......
......@@ -56,65 +56,6 @@ static void *mymalloc(size_t size);
static void *myrealloc(void *ptr, size_t size);
static char *mystrdup(const char *str);
static int
emulab_init(void)
{
static int called;
char pathbuf[PATH_MAX], *path;
if (!dbinit())
return -1;
if (called)
return 0;
called++;
/* One time parsing of MC address info */
if (sscanf(MC_BASEADDR, "%d.%d.%d", &mc_a, &mc_b, &mc_c) != 3) {
error("emulab_init: MC_BASEADDR '%s' not in A.B.C format!",
MC_BASEADDR);
return -1;
}
mc_port = atoi(MC_BASEPORT);
if ((path = realpath(SHAREROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", SHAREROOT_DIR);
return -1;
}
SHAREDIR = mystrdup(path);
if ((path = realpath(PROJROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", PROJROOT_DIR);
return -1;
}
PROJDIR = mystrdup(path);
if ((path = realpath(GROUPSROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", GROUPSROOT_DIR);
return -1;
}
GROUPSDIR = mystrdup(path);
if ((path = realpath(USERSROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", USERSROOT_DIR);
return -1;
}
USERSDIR = mystrdup(path);
if (strlen(SCRATCHROOT_DIR) > 0) {
if ((path = realpath(SCRATCHROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'",
SCRATCHROOT_DIR);
return -1;
}
SCRATCHDIR = mystrdup(path);
} else
SCRATCHDIR = NULL;
log("Read Emulab configuration");
return 0;
}
static void
emulab_deinit(void)
{
......@@ -152,7 +93,7 @@ emulab_free(void *state)
* Set the allowed GET methods.
* XXX for now, just multicast.
*/
void
static void
set_get_methods(struct config_host_authinfo *ai, int ix)
{
ai->imageinfo[ix].get_methods = CONFIG_IMAGE_MCAST;
......@@ -169,7 +110,7 @@ set_get_methods(struct config_host_authinfo *ai, int ix)
* loading a "standard" image: 72Mb/sec
* any other image: 54Mb/sec
*/
void
static void
set_get_options(struct config_host_authinfo *ai, int ix)
{
char str[256];
......@@ -1017,7 +958,7 @@ dump_image_aliases(FILE *fd)
" GROUP by e.pid,e.gid", 2);
assert(res != NULL);
lastpid = strdup("NONE");
lastpid = mystrdup("NONE");
nrows = mysql_num_rows(res);
for (i = 0; i < nrows; i++) {
MYSQL_RES *res2;
......@@ -1033,7 +974,7 @@ dump_image_aliases(FILE *fd)
/* New pid, put out shared project image alias */
if (strcmp(lastpid, row[0])) {
free(lastpid);
lastpid = strdup(row[0]);
lastpid = mystrdup(row[0]);
res2 = mydb_query("SELECT imagename"
" FROM images"
......@@ -1134,7 +1075,6 @@ emulab_dump(FILE *fd)
}
struct config emulab_config = {
emulab_init,
emulab_deinit,
emulab_read,
emulab_get_host_authinfo,
......@@ -1146,6 +1086,65 @@ struct config emulab_config = {
emulab_dump
};
struct config *
emulab_init(void)
{
static int called;
char pathbuf[PATH_MAX], *path;
if (!dbinit())
return NULL;
if (called)
return &emulab_config;
called++;
/* One time parsing of MC address info */
if (sscanf(MC_BASEADDR, "%d.%d.%d", &mc_a, &mc_b, &mc_c) != 3) {
error("emulab_init: MC_BASEADDR '%s' not in A.B.C format!",
MC_BASEADDR);
return NULL;
}
mc_port = atoi(MC_BASEPORT);
if ((path = realpath(SHAREROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", SHAREROOT_DIR);
return NULL;
}
SHAREDIR = mystrdup(path);
if ((path = realpath(PROJROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", PROJROOT_DIR);
return NULL;
}
PROJDIR = mystrdup(path);
if ((path = realpath(GROUPSROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", GROUPSROOT_DIR);
return NULL;
}
GROUPSDIR = mystrdup(path);
if ((path = realpath(USERSROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'", USERSROOT_DIR);
return NULL;
}
USERSDIR = mystrdup(path);
if (strlen(SCRATCHROOT_DIR) > 0) {
if ((path = realpath(SCRATCHROOT_DIR, pathbuf)) == NULL) {
error("emulab_init: could not resolve '%s'",
SCRATCHROOT_DIR);
return NULL;
}
SCRATCHDIR = mystrdup(path);
} else
SCRATCHDIR = NULL;
log("Read Emulab configuration");
return &emulab_config;
}
/*
* XXX memory allocation functions that either return memory or abort.
* We shouldn't run out of memory and don't want to check every return values.
......@@ -1219,4 +1218,11 @@ warning(const char *fmt, ...)
}
#endif
#else
struct config *
emulab_init(void)
{
return NULL;
}
#endif
This diff is collapsed.
......@@ -42,7 +42,6 @@ struct config_host_authinfo {
* Config file functions
*/
struct config {
int (*config_init)(void);
void (*config_deinit)(void);
int (*config_read)(void);
int (*config_get_host_authinfo)(struct in_addr *,
......
......@@ -53,6 +53,7 @@ static int parentport = MS_PORTNUM;
static int fetchfromabove = 0;
static int canredirect = 0;
static int usechildauth = 0;
static int mirrormode = 0;
/* XXX the following just keep network.c happy */
int portnum = MS_PORTNUM;
......@@ -76,7 +77,8 @@ main(int argc, char **argv)
log("mfrisbee daemon starting, methods=%s (debug level %d)",
GetMSMethods(onlymethods), debug);
if (fetchfromabove)
log(" using parent %s:%d", inet_ntoa(parentip), parentport);
log(" using parent %s:%d%s", inet_ntoa(parentip), parentport,
mirrormode ? " in mirror mode" : "");
config_init(1);
/* Just dump the config to stdout in human readable form and exit. */
......@@ -336,7 +338,9 @@ handle_get(int sock, struct sockaddr_in *sip, struct sockaddr_in *cip,
/*
* If an explicit host was listed, use that as the host we are
* authenticating, otherwise use the caller's IP.
* authenticating, otherwise use the caller's IP. config_auth_by_IP
* will reject the former if the caller is not allowed to proxy for
* the node in question.
*/
if (msg->body.getrequest.hostip)
host.s_addr = msg->body.getrequest.hostip;
......@@ -360,6 +364,7 @@ handle_get(int sock, struct sockaddr_in *sip, struct sockaddr_in *cip,
memset(msg, 0, sizeof *msg);
msg->type = htonl(MS_MSGTYPE_GETREPLY);
strncpy((char *)msg->version, MS_MSGVERS_1, sizeof(msg->version));
/*
* If they request a method we don't support, reject them before
......@@ -369,27 +374,28 @@ handle_get(int sock, struct sockaddr_in *sip, struct sockaddr_in *cip,
if (methods == 0)
goto badmethod;
/*
* See if node has access to the image.
* If not, return an error code immediately.
*/
rv = config_auth_by_IP(&cip->sin_addr, &host, imageid, &ai);
if (rv) {
warning("%s: client %s %s failed: %s",
imageid, clientip, op, GetMSError(rv));
msg->body.getreply.error = rv;
goto reply;
}
if (debug > 1)
config_dump_host_authinfo(ai);
if (ai->numimages > 1) {
rv = MS_ERROR_INVALID;
warning("%s: client %s %s failed: "
"lookup returned multiple (%d) images",
imageid, clientip, op, ai->numimages);
msg->body.getreply.error = rv;
goto reply;
if (!mirrormode) {
/*
* See if node has access to the image.
* If not, return an error code immediately.
*/
rv = config_auth_by_IP(&cip->sin_addr, &host, imageid, &ai);
if (rv) {
warning("%s: client %s %s failed: %s",
imageid, clientip, op, GetMSError(rv));
msg->body.getreply.error = rv;
goto reply;
}
if (debug > 1)
config_dump_host_authinfo(ai);
if (ai->numimages > 1) {
rv = MS_ERROR_INVALID;
warning("%s: client %s %s failed: "
"lookup returned multiple (%d) images",
imageid, clientip, op, ai->numimages);
msg->body.getreply.error = rv;
goto reply;
}
}
ii = &ai->imageinfo[0];
assert((ii->flags & CONFIG_PATH_ISFILE) != 0);
......@@ -677,7 +683,7 @@ get_options(int argc, char **argv)
{
int ch;
while ((ch = getopt(argc, argv, "AC:DRS:P:p:dh")) != -1)
while ((ch = getopt(argc, argv, "AC:DI:RS:P:p:dh")) != -1)
switch(ch) {
case 'A':
usechildauth = 1;
......@@ -715,6 +721,15 @@ get_options(int argc, char **argv)
case 'D':
dumpconfig = 1;
break;
case 'I':
{
extern char *imagedir;
imagedir = optarg;
break;
}
case 'M':
mirrormode = 1;
break;
case 'R':
canredirect = 1;
break;
......@@ -746,6 +761,12 @@ get_options(int argc, char **argv)
argv[0]);
usage();
}
if (mirrormode && !fetchfromabove) {
fprintf(stderr,
"Error: Must specify a parent (-S) in mirror mode\n");
usage();
}
}
/*
......
......@@ -654,7 +654,7 @@ ClientNetFindServer(in_addr_t sip, in_port_t sport,
}
memset(&msg, 0, sizeof msg);
strncpy(msg.version, MS_MSGVERS_1, sizeof(msg.version));
strncpy((char *)msg.version, MS_MSGVERS_1, sizeof(msg.version));
msg.type = htonl(MS_MSGTYPE_GETREQUEST);
msg.body.getrequest.hostip = htonl(hostip);
if (askonly) {
......@@ -682,7 +682,7 @@ ClientNetFindServer(in_addr_t sip, in_port_t sport,
return 0;
}
if (strncmp(msg.version, MS_MSGVERS_1, sizeof(msg.version))) {
if (strncmp((char *)msg.version, MS_MSGVERS_1, sizeof(msg.version))) {
fprintf(stderr, "Got incorrect version from master server\n");
close(msock);
return 0;
......
......@@ -51,6 +51,17 @@ case "$1" in
@prefix@/sbin/sslxmlrpc_server.py
fi
if [ -x @prefix@/sbin/mfrisbeed ]; then
echo -n " mfrisbeed"
if [ -x @prefix@/sbin/daemon_wrapper ]; then
@prefix@/sbin/daemon_wrapper \
-i 30 -l @prefix@/log/mfrisbeed_wrapper.log \
@prefix@/sbin/mfrisbeed
else
@prefix@/sbin/mfrisbeed
fi
fi
if [ -x @prefix@/sbin/reload_daemon ]; then
echo -n " reloadd"
@prefix@/sbin/reload_daemon
......
......@@ -43,12 +43,14 @@ my $PROJROOT = "@PROJROOT_DIR@";
# for the occasional pxeboot failure.
my $MAXRETRIES = 1;
my $OUTERBOSS = "@OUTERBOSS_NODENAME@";
my $FRISBEELAUNCHER = "$TB/sbin/frisbeelauncher";
my $SUBBOSS_FRISBEELAUNCHER = "$TB/sbin/subboss_frisbeelauncher_wrapper";
my $osselect = "$TB/bin/os_select";
my $TBUISP = "$TB/bin/tbuisp";
# Locals
my $FRISBEE = "$TB/sbin/frisbee";
my %imageinfo = (); # Per imageid DB info.
my $debug = 0;
my %children = (); # Child pids in when asyncmode=1
......@@ -742,6 +744,7 @@ sub osload ($$) {
sub GetImageInfo($;$)
{
my ($image, $node) = @_;
my $imagesize = 0;
my $imageid = $image->imageid();
my $rowref = $image->DBData();
......@@ -765,40 +768,46 @@ sub GetImageInfo($;$)
}
if (! -R $imagepath) {
#
# If the image doesn't exist and we are in an inner elab,
# make sure real boss has it and see how big it is.
#
# Note that we don't actually pre-fetch the image here,
# that will be done automatically when the image is first requested.
#
if ($ELABINELAB) {
#
# Yuck. See if we can get it via frisbeelauncher before giving up.
#
system("$FRISBEELAUNCHER " . ($debug ? "-d ": "") . "$imageid");
if ($?) {
tberror "Frisbeelauncher ($image) failed!";
$imageinfo{$imageid} = 'BADIMAGE';
return 0;
}
if (! -R $imagepath) {
tberror "Frisbeelauncher could not fetch $imagepath ($image)!";
my $frisimageid = $rowref->{'pid'} . "/" . $rowref->{'imagename'};
my $attr = `$FRISBEE -S $OUTERBOSS -Q $frisimageid`;
if ($attr =~ /error=0/) {
if ($attr =~ /size=(\d+)/) {
$imagesize = $1;
} else {
$imagesize = 1 * 1024 * 1024 * 1024;
}
} else {
tberror "Query to $OUTERBOSS for info on $image failed!";
$imageinfo{$imageid} = 'BADIMAGE';
return 0;
}
}
else {
} else {
tberror "$imagepath does not exist or cannot be read!";
$imageinfo{$imageid} = 'BADIMAGE';
return 0;
}
}
my $sb = stat($imagepath);
} else {
$imagesize = stat($imagepath)->size;
#
# A zero-length image cannot be right and will result in much confusion
# if allowed to pass: the image load will succeed, but the disk will be
# unchanged, making it appear that os_load loaded the default image.
#
if ($sb->size == 0) {
tberror "$imagepath is empty!";
$imageinfo{$imageid} = 'BADIMAGE';
return 0;
#
# A zero-length image cannot be right and will result in much confusion
# if allowed to pass: the image load will succeed, but the disk will be
# unchanged, making it appear that os_load loaded the default image.
#
if ($imagesize == 0) {
tberror "$imagepath is empty!";
$imageinfo{$imageid} = 'BADIMAGE';
return 0;
}
}
#
......@@ -808,7 +817,7 @@ sub GetImageInfo($;$)
# image DB state, so we store it in the imageinfo array too.
#
if (!defined($rowref->{'maxloadwait'})) {
my $chunks = $sb->size >> 20; # size may be > 2^31, shift is unsigned
my $chunks = $imagesize >> 20; # size may be > 2^31, shift is unsigned
$rowref->{'maxloadwait'} = int((($chunks / 100.0) * 65) + (5 * 60));
}
......@@ -817,6 +826,7 @@ sub GetImageInfo($;$)
"$image: loadpart=", $rowref->{'loadpart'},
", loadlen=", $rowref->{'loadlength'},
", imagepath=", $rowref->{'path'},
", imagesize=", $imagesize,
", defosid=", $rowref->{'default_osid'},
", maxloadwait=", $rowref->{'maxloadwait'}, "\n"
if ($debug);
......@@ -1040,6 +1050,7 @@ sub SetupReloadFrisbee($)
TBSetNodeEventState($node,TBDB_NODESTATE_SHUTDOWN);
}
if (0) {
foreach my $imageid (@$imageids) {
if (defined $subboss) {
my $image = Image->Lookup($imageid);
......@@ -1066,6 +1077,7 @@ sub SetupReloadFrisbee($)
return -1;
}
}
}
return 0;
}
......
......@@ -26,4 +26,4 @@
* NB: See ron/libsetup.pm. That is version 4! I'll merge that in.
*/
#define DEFAULT_VERSION 2
#define CURRENT_VERSION 32
#define CURRENT_VERSION 33
......@@ -142,15 +142,16 @@ loadone() {
for parm in $_LOADINFO; do
case $parm in
ADDR=*|\
SERVER=*|\
PART=*|\
PARTOS=*|\
SERVER=*|\
DISK=*|\
ZFILL=*|\
ACPI=*|\
ASF=*|\
MBRVERS=*|\
PREPARE=*)
ASF=*|\
PREPARE=*|\
IMAGEID=*)
# XXX need to parse better, eval is dangerous!
eval $parm
;;
......@@ -162,7 +163,7 @@ loadone() {
#
# Assign defaults where needed.
# Assumed to be set: ADDR
# Assumed to be set: ADDR or IMAGEID
#
SERVER=${SERVER:-$BOSSIP}
PART=${PART:-'0'}
......@@ -174,6 +175,17 @@ loadone() {
MBRVERS=${MBRVERS:-'1'}
PREPARE=${PREPARE:-'0'}
if [ x"$IMAGEID" != x ]; then
ADDR=""
# IMAGEID=pid,gid,imagename
pid=`echo $IMAGEID | awk -F, '{ printf $1 }'`
name=`echo $IMAGEID | awk -F, '{ printf $3 }'`
IMAGEID="$pid/$name"
elif [ x"$ADDR" = x ]; then
echo "Unable to get imageid or address for loading image"
return 1
fi
if [ "$PART" != "0" ]; then
SLICE="-s $PART"
case $PARTOS in
......@@ -223,9 +235,9 @@ loadone() {
fi
#
# Make sure the necessary device files exist (only necessary on FreeBSD 4.x)
# Note that we create partition files for all slices, not just slice 1,
# for the benefit of the slicefix script.
# Make sure the necessary device files exist (only necessary on
# FreeBSD 4.x). Note that we create partition files for all slices,
# not just slice 1, for the benefit of the slicefix script.
#
if [ -x /dev/MAKEDEV -a ! -e /dev/$DISK ]; then
(cd /dev; ./MAKEDEV $DISK ${DISK}s2a ${DISK}s3a ${DISK}s4a)
......@@ -257,7 +269,7 @@ loadone() {
return 1
fi
imagefile="$ADDR"
else
else
PORT=`echo $ADDR | awk -F: '{ printf $2 }'`
MCAST=`echo $ADDR | awk -F: '{ printf $1 }'`
if [ -e $BOOTDIR/myip ]; then
......@@ -266,139 +278,141 @@ loadone() {
MCASTIF=""
fi
MCASTADDR="-m $MCAST -p $PORT"
IMAGEID="$MCASTIF $MCASTADDR"
isurl=0
ispath=0
fi
else
IMAGEID="-B 30 -F $IMAGEID"
isurl=0
ispath=0
fi
#
# ZFILL==1: use frisbee
# ZFILL==2: separate disk-wipe pass (not yet implemented)
#
if [ "$ZFILL" != "0" ]; then
ZFILL="-z"
else
ZFILL=""
fi
#
# Make sure the write-cache is enabled on SCSI disks. It makes a
# huge difference. We don't worry about data corruption in the
# case of a crash, because we will just reload the disk again anyway
# in that situation.
#
turncacheoff=0
case $DISK in
da*)
if [ -x $BINDIR/camwce ] && $BINDIR/camwce on $DISK; then
turncacheoff=1;
fi
;;
esac
#
# For slice images, ensure that the MBR is the correct version
# and replace if not.
#
if [ $_NUM -eq 0 ]; then
if [ "$PART" != "0" ]; then
tweakmbr $DISK $MBRVERS
fi
FIRSTMBR=$MBRVERS
else
if [ "$FIRSTMBR" != "$MBRVERS" ]; then
echo "MBR Mismatch: First MBR is \"$FIRSTMBR\" while image #$_NUM is \"$MBRVERS\""
fi
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
echo "Downloading image \'$ADDR\' to /images directory ..."
$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"
return 1
}
}
wget -nv -N -P /images "$ADDR"
wstat=$?
case $wstat in
0)
echo "wget succeeded getting the image"
;;
*)
echo "wget failed, status $wstat"
return 1
;;
esac
fi
#
# ZFILL==1: use frisbee
# ZFILL==2: separate disk-wipe pass (not yet implemented)
#
if [ "$ZFILL" != "0" ]; then
ZFILL="-z"
else
ZFILL=""
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
# that might leak through (most likely in partition 4 which isn't
# touched by our current image). We do this before running frisbee
# so that any legit filesystems loaded from the image work.
#
# Since we do it before frisbee, we are counting on the current
# MBR being the same as the MBR being layed down. While not
# a reasonable assumption in general, it mostly works in our
# environment and at least won't hurt anything if not true.