From 0aba0db353a5aa6e823d28e78af61de7bc0cb052 Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Thu, 8 Mar 2012 13:52:32 -0700 Subject: [PATCH] Look for a /.localized in the root of the MFS to determine if the MFS is indeed localized. --- clientside/tmcc/freebsd/slicefix | 259 ++++++++++++++++--------------- 1 file changed, 137 insertions(+), 122 deletions(-) diff --git a/clientside/tmcc/freebsd/slicefix b/clientside/tmcc/freebsd/slicefix index 5f9a3bfa3..4f1ab96b9 100755 --- a/clientside/tmcc/freebsd/slicefix +++ b/clientside/tmcc/freebsd/slicefix @@ -104,6 +104,17 @@ else setboss=0 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() { # # ARGH! FreeBSD 5, which primarily uses UFS2, internally converts @@ -295,62 +306,64 @@ dofreebsd() { fi fi - # Check the certs. - if [ -e $ETCDIR/emulab.pem ]; then - cmp -s $ETCDIR/emulab.pem /mnt/etc/emulab/emulab.pem + if islocalized; then + # Check the certs. + if [ -e $ETCDIR/emulab.pem ]; then + cmp -s $ETCDIR/emulab.pem /mnt/etc/emulab/emulab.pem - if [ $? -ne 0 ]; then - changecerts=1 - fixit=1 + if [ $? -ne 0 ]; then + changecerts=1 + fixit=1 + fi fi - fi - if [ -e $ETCDIR/client.pem ]; then - cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem + if [ -e $ETCDIR/client.pem ]; then + cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem - if [ $? -ne 0 ]; then - changecerts=1 - fixit=1 + if [ $? -ne 0 ]; then + changecerts=1 + fixit=1 + fi fi - fi - # Check the root keys - if [ -e /root/.ssh/authorized_keys2 ]; then - cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys - if [ $? -ne 0 ]; then - changerootkeys=1 - fixit=1 + # Check the root keys + if [ -e /root/.ssh/authorized_keys2 ]; then + cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys + if [ $? -ne 0 ]; then + changerootkeys=1 + fixit=1 + fi fi - fi - # Check the host keys. - 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 - if [ $? -ne 0 ]; then - changehostkeys=1 - fixit=1 + # Check the host keys. + 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 + if [ $? -ne 0 ]; then + changehostkeys=1 + fixit=1 + fi fi - fi - 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 - if [ $? -ne 0 ]; then - changehostkeys=1 - fixit=1 + 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 + if [ $? -ne 0 ]; then + changehostkeys=1 + fixit=1 + fi fi - fi - 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 - if [ $? -ne 0 ]; then - changehostkeys=1 - fixit=1 + 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 + if [ $? -ne 0 ]; then + changehostkeys=1 + fixit=1 + fi fi - fi - # Check the time zone. - if [ -e /etc/localtime ]; then - cmp -s /etc/localtime /mnt/etc/localtime - if [ $? -ne 0 ]; then - changezone=1 - fixit=1 + # Check the time zone. + if [ -e /etc/localtime ]; then + cmp -s /etc/localtime /mnt/etc/localtime + if [ $? -ne 0 ]; then + changezone=1 + fixit=1 + fi fi fi @@ -725,107 +738,109 @@ dolinux() { fi # Check the certs. - if [ ! -d /mnt/etc/emulab ]; then - mkdir -m 755 /mnt/etc/emulab || { - echo "Failed to mkdir /mnt/etc/emulab" - umount $rootdev - 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" + if islocalized; then + if [ ! -d /mnt/etc/emulab ]; then + mkdir -m 755 /mnt/etc/emulab || { + echo "Failed to mkdir /mnt/etc/emulab" umount $rootdev return 1 } fi - fi - if [ -e $ETCDIR/client.pem ]; then - cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem + 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/client.pem" - cp -p $ETCDIR/client.pem /mnt/etc/emulab || { - echo "Failed to create $ETCDIR/client.pem" - umount $rootdev - return 1 - } + 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 + return 1 + } + fi fi - fi + if [ -e $ETCDIR/client.pem ]; then + cmp -s $ETCDIR/client.pem /mnt/etc/emulab/client.pem - # Check the root keys - if [ -e /root/.ssh/authorized_keys2 ]; then - cmp -s /root/.ssh/authorized_keys2 /mnt/root/.ssh/authorized_keys - if [ $? -ne 0 ]; then - echo " updating /root/.ssh/authorized_keys2" + if [ $? -ne 0 ]; then + echo " updating /mnt/etc/emulab/client.pem" + cp -p $ETCDIR/client.pem /mnt/etc/emulab || { + echo "Failed to create $ETCDIR/client.pem" + umount $rootdev + return 1 + } + fi + fi - if [ ! -d /mnt/root/.ssh ]; then - mkdir -m 700 /mnt/root/.ssh || { - echo "Failed to mkdir /root/.ssh" + # Check the root keys + if [ -e /root/.ssh/authorized_keys2 ]; then + 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 return 1 } fi - cp -p /root/.ssh/authorized_keys2 /mnt/root/.ssh || { - echo "Failed to create /root/.ssh/authorized_keys2" - umount $rootdev - return 1 - } fi - fi - changehostkeys=0 - # Check the host keys. - 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 - if [ $? -ne 0 ]; then - changehostkeys=1 + changehostkeys=0 + # Check the host keys. + 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 + if [ $? -ne 0 ]; then + changehostkeys=1 + fi fi - fi - 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 - if [ $? -ne 0 ]; then - changehostkeys=1 + 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 + if [ $? -ne 0 ]; then + changehostkeys=1 + fi fi - fi - 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 - if [ $? -ne 0 ]; then - changehostkeys=1 + 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 + if [ $? -ne 0 ]; then + changehostkeys=1 + fi fi - fi - if [ $changehostkeys -eq 1 ]; then - echo " updating /etc/ssh/hostkeys" + if [ $changehostkeys -eq 1 ]; then + echo " updating /etc/ssh/hostkeys" - if [ ! -d /mnt/etc/ssh ]; then - mkdir -m 755 /mnt/etc/ssh || { - echo "Failed to mkdir /mnt/etc/ssh" + if [ ! -d /mnt/etc/ssh ]; then + mkdir -m 755 /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 return 1 } 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. - if [ -e /etc/localtime ]; then - cmp -s /etc/localtime /mnt/etc/localtime - if [ $? -ne 0 ]; then - echo " updating /etc/localtime" + # Check the time zone. + if [ -e /etc/localtime ]; then + cmp -s /etc/localtime /mnt/etc/localtime + if [ $? -ne 0 ]; then + echo " updating /etc/localtime" - cp -p /etc/localtime /mnt/etc/localtime || { - echo "Failed to create /etc/localtime" - umount $rootdev - return 1 - } + cp -p /etc/localtime /mnt/etc/localtime || { + echo "Failed to create /etc/localtime" + umount $rootdev + return 1 + } + fi fi fi -- GitLab