Commit 0aba0db3 authored by Leigh B Stoller's avatar Leigh B Stoller

Look for a /.localized in the root of the MFS to determine if the MFS

is indeed localized.
parent f6a3c910
...@@ -104,6 +104,17 @@ else ...@@ -104,6 +104,17 @@ else
setboss=0 setboss=0
fi fi
# Indicates the MFS has been properly localized and we can copy stuff
# into the image.
LOCALIZED="/.localized"
islocalized() {
if [ -e $LOCALIZED ]; then
return 0;
fi
return 1;
}
dofreebsd() { dofreebsd() {
# #
# ARGH! FreeBSD 5, which primarily uses UFS2, internally converts # ARGH! FreeBSD 5, which primarily uses UFS2, internally converts
...@@ -295,62 +306,64 @@ dofreebsd() { ...@@ -295,62 +306,64 @@ dofreebsd() {
fi fi
fi fi
# Check the certs. if islocalized; then
if [ -e $ETCDIR/emulab.pem ]; then # Check the certs.
cmp -s $ETCDIR/emulab.pem /mnt/etc/emulab/emulab.pem if [ -e $ETCDIR/emulab.pem ]; then
cmp -s $ETCDIR/emulab.pem /mnt/etc/emulab/emulab.pem
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
changecerts=1 changecerts=1
fixit=1 fixit=1
fi
fi fi
fi if [ -e $ETCDIR/client.pem ]; then
if [ -e $ETCDIR/client.pem ]; then cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem
cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
changecerts=1 changecerts=1
fixit=1 fixit=1
fi
fi fi
fi
# Check the root keys # Check the root keys
if [ -e /root/.ssh/authorized_keys2 ]; then if [ -e /root/.ssh/authorized_keys2 ]; then
cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
changerootkeys=1 changerootkeys=1
fixit=1 fixit=1
fi
fi fi
fi
# Check the host keys. # Check the host keys.
if [ -e /etc/ssh/ssh_host_key -a -d /mnt/etc/ssh ]; then if [ -e /etc/ssh/ssh_host_key -a -d /mnt/etc/ssh ]; then
cmp -s /etc/ssh/ssh_host_key /mnt/etc/ssh/ssh_host_key cmp -s /etc/ssh/ssh_host_key /mnt/etc/ssh/ssh_host_key
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
changehostkeys=1 changehostkeys=1
fixit=1 fixit=1
fi
fi fi
fi if [ -e /etc/ssh/ssh_host_rsa_key -a -d /mnt/etc/ssh ]; then
if [ -e /etc/ssh/ssh_host_rsa_key -a -d /mnt/etc/ssh ]; then cmp -s /etc/ssh/ssh_host_rsa_key /mnt/etc/ssh/ssh_host_rsa_key
cmp -s /etc/ssh/ssh_host_rsa_key /mnt/etc/ssh/ssh_host_rsa_key if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then changehostkeys=1
changehostkeys=1 fixit=1
fixit=1 fi
fi fi
fi if [ -e /etc/ssh/ssh_host_dsa_key -a -d /mnt/etc/ssh ]; then
if [ -e /etc/ssh/ssh_host_dsa_key -a -d /mnt/etc/ssh ]; then cmp -s /etc/ssh/ssh_host_dsa_key /mnt/etc/ssh/ssh_host_dsa_key
cmp -s /etc/ssh/ssh_host_dsa_key /mnt/etc/ssh/ssh_host_dsa_key if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then changehostkeys=1
changehostkeys=1 fixit=1
fixit=1 fi
fi fi
fi
# Check the time zone. # Check the time zone.
if [ -e /etc/localtime ]; then if [ -e /etc/localtime ]; then
cmp -s /etc/localtime /mnt/etc/localtime cmp -s /etc/localtime /mnt/etc/localtime
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
changezone=1 changezone=1
fixit=1 fixit=1
fi
fi fi
fi fi
...@@ -725,107 +738,109 @@ dolinux() { ...@@ -725,107 +738,109 @@ dolinux() {
fi fi
# Check the certs. # Check the certs.
if [ ! -d /mnt/etc/emulab ]; then if islocalized; then
mkdir -m 755 /mnt/etc/emulab || { if [ ! -d /mnt/etc/emulab ]; then
echo "Failed to mkdir /mnt/etc/emulab" mkdir -m 755 /mnt/etc/emulab || {
umount $rootdev echo "Failed to mkdir /mnt/etc/emulab"
return 1
}
fi
if [ -e $ETCDIR/emulab.pem ]; then
cmp -s $ETCDIR/emulab.pem /mnt/etc/emulab/emulab.pem
if [ $? -ne 0 ]; then
echo " updating /mnt/etc/emulab/emulab.pem"
cp -p $ETCDIR/emulab.pem /mnt/etc/emulab || {
echo "Failed to create $ETCDIR/emulab.pem"
umount $rootdev umount $rootdev
return 1 return 1
} }
fi fi
fi if [ -e $ETCDIR/emulab.pem ]; then
if [ -e $ETCDIR/client.pem ]; then cmp -s $ETCDIR/emulab.pem /mnt/etc/emulab/emulab.pem
cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo " updating /mnt/etc/emulab/client.pem" echo " updating /mnt/etc/emulab/emulab.pem"
cp -p $ETCDIR/client.pem /mnt/etc/emulab || { cp -p $ETCDIR/emulab.pem /mnt/etc/emulab || {
echo "Failed to create $ETCDIR/client.pem" echo "Failed to create $ETCDIR/emulab.pem"
umount $rootdev umount $rootdev
return 1 return 1
} }
fi
fi fi
fi if [ -e $ETCDIR/client.pem ]; then
cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem
# Check the root keys if [ $? -ne 0 ]; then
if [ -e /root/.ssh/authorized_keys2 ]; then echo " updating /mnt/etc/emulab/client.pem"
cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys cp -p $ETCDIR/client.pem /mnt/etc/emulab || {
if [ $? -ne 0 ]; then echo "Failed to create $ETCDIR/client.pem"
echo " updating /root/.ssh/authorized_keys2" umount $rootdev
return 1
}
fi
fi
if [ ! -d /mnt/root/.ssh ]; then # Check the root keys
mkdir -m 700 /mnt/root/.ssh || { if [ -e /root/.ssh/authorized_keys2 ]; then
echo "Failed to mkdir /root/.ssh" cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys
if [ $? -ne 0 ]; then
echo " updating /root/.ssh/authorized_keys2"
if [ ! -d /mnt/root/.ssh ]; then
mkdir -m 700 /mnt/root/.ssh || {
echo "Failed to mkdir /root/.ssh"
umount $rootdev
return 1
}
fi
cp -p /root/.ssh/authorized_keys2 /mnt/root/.ssh || {
echo "Failed to create /root/.ssh/authorized_keys2"
umount $rootdev umount $rootdev
return 1 return 1
} }
fi fi
cp -p /root/.ssh/authorized_keys2 /mnt/root/.ssh || {
echo "Failed to create /root/.ssh/authorized_keys2"
umount $rootdev
return 1
}
fi fi
fi
changehostkeys=0 changehostkeys=0
# Check the host keys. # Check the host keys.
if [ -e /etc/ssh/ssh_host_key -a -d /mnt/etc/ssh ]; then if [ -e /etc/ssh/ssh_host_key -a -d /mnt/etc/ssh ]; then
cmp -s /etc/ssh/ssh_host_key /mnt/etc/ssh/ssh_host_key cmp -s /etc/ssh/ssh_host_key /mnt/etc/ssh/ssh_host_key
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
changehostkeys=1 changehostkeys=1
fi
fi fi
fi if [ -e /etc/ssh/ssh_host_rsa_key -a -d /mnt/etc/ssh ]; then
if [ -e /etc/ssh/ssh_host_rsa_key -a -d /mnt/etc/ssh ]; then cmp -s /etc/ssh/ssh_host_rsa_key /mnt/etc/ssh/ssh_host_rsa_key
cmp -s /etc/ssh/ssh_host_rsa_key /mnt/etc/ssh/ssh_host_rsa_key if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then changehostkeys=1
changehostkeys=1 fi
fi fi
fi if [ -e /etc/ssh/ssh_host_dsa_key -a -d /mnt/etc/ssh ]; then
if [ -e /etc/ssh/ssh_host_dsa_key -a -d /mnt/etc/ssh ]; then cmp -s /etc/ssh/ssh_host_dsa_key /mnt/etc/ssh/ssh_host_dsa_key
cmp -s /etc/ssh/ssh_host_dsa_key /mnt/etc/ssh/ssh_host_dsa_key if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then changehostkeys=1
changehostkeys=1 fi
fi fi
fi if [ $changehostkeys -eq 1 ]; then
if [ $changehostkeys -eq 1 ]; then echo " updating /etc/ssh/hostkeys"
echo " updating /etc/ssh/hostkeys"
if [ ! -d /mnt/etc/ssh ]; then if [ ! -d /mnt/etc/ssh ]; then
mkdir -m 755 /mnt/etc/ssh || { mkdir -m 755 /mnt/etc/ssh || {
echo "Failed to mkdir /mnt/etc/ssh" echo "Failed to mkdir /mnt/etc/ssh"
umount $rootdev
return 1
}
fi
cp -p /etc/ssh/ssh_host_* /mnt/etc/ssh || {
echo "Failed to create /etc/ssh/hostkeys"
umount $rootdev umount $rootdev
return 1 return 1
} }
fi fi
cp -p /etc/ssh/ssh_host_* /mnt/etc/ssh || {
echo "Failed to create /etc/ssh/hostkeys"
umount $rootdev
return 1
}
fi
# Check the time zone. # Check the time zone.
if [ -e /etc/localtime ]; then if [ -e /etc/localtime ]; then
cmp -s /etc/localtime /mnt/etc/localtime cmp -s /etc/localtime /mnt/etc/localtime
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo " updating /etc/localtime" echo " updating /etc/localtime"
cp -p /etc/localtime /mnt/etc/localtime || { cp -p /etc/localtime /mnt/etc/localtime || {
echo "Failed to create /etc/localtime" echo "Failed to create /etc/localtime"
umount $rootdev umount $rootdev
return 1 return 1
} }
fi
fi fi
fi fi
......
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