[PC-BSD Commits] r5118 - pcbsd/trunk/pc-sysinstall/backend

svn at pcbsd.org svn at pcbsd.org
Sun Nov 22 13:20:05 PST 2009


Author: kris
Date: 2009-11-22 13:20:05 -0800 (Sun, 22 Nov 2009)
New Revision: 5118

Modified:
   pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh
Log:

Fixed bugs with the autoinstall script in pc-sysconfig



Modified: pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh	2009-11-22 10:01:50 UTC (rev 5117)
+++ pcbsd/trunk/pc-sysinstall/backend/startautoinstall.sh	2009-11-22 21:20:05 UTC (rev 5118)
@@ -19,44 +19,54 @@
 INSTALL_CFG="/tmp/pc-sysinstall.cfg"
 
 # Check if the config file is on disk as well
-PC-CFG=`grep "pc_config:" ${CONF} | grep -v "^#" | cut -d ':' -f 2 | tr -d ' '`
+PCCFG=`grep "pc_config:" ${CONF} | grep -v "^#" | sed "s|pc_config: ||g" | sed "s|pc_config:||g"`
 SHUTDOWN_CMD=`grep "shutdown_cmd:" ${CONF} | grep -v "^#" | sed "s|shutdown_cmd: ||g" | sed "s|shutdown_cmd:||g"`
 SHUTDOWN_CMD=`grep "shutdown_cmd:" ${CONF} | grep -v "^#" | sed "s|shutdown_cmd: ||g" | sed "s|shutdown_cmd:||g"`
 CONFIRM_INS=`grep "confirm_install:" ${CONF} | grep -v "^#" | sed "s|confirm_install: ||g" | sed "s|confirm_install:||g"`
 
 # Check that this isn't a http / ftp file we need to fetch later
-echo "${PC-CFG}" | grep -e "^http" -e "^ftp" > /dev/null 2>/dev/null
+echo "${PCCFG}" | grep -e "^http" -e "^ftp" > /dev/null 2>/dev/null
 if [ "$?" != "0" ]
 then
+  # Copy over the install cfg file, if not done already
+  if [ ! -e "${INSTALL_CFG}" ]
+  then
+    cp ${PCCFG} ${INSTALL_CFG}
+  fi
   # Make sure we have the file which was copied into /tmp previously
   if [ ! -e "${INSTALL_CFG}" ]
   then
-    echo "Error: ${INSTALL_CFG} is missing! Continuing in 10 seconds..."
+    echo "Error: ${INSTALL_CFG} is missing! Exiting in 10 seconds..."
     sleep 10
     exit 150
   fi
 else
   # We need to fetch a remote file, check and set any nic options before doing so
-  NIC-CFG=`grep "nic_config:" ${CONF} | grep -v "^#" | sed "s|nic_config: ||g" | sed "s|nic_config:||g"`
-  if [ "${NIC-CFG}" = "dhcp-all" ]
+  NICCFG=`grep "nic_config:" ${CONF} | grep -v "^#" | sed "s|nic_config: ||g" | sed "s|nic_config:||g"`
+  if [ "${NICCFG}" = "dhcp-all" ]
   then
     # Try to auto-enable dhcp on any nics we find
     enable_auto_dhcp
   else
-    echo "Running command \"ifconfig ${NIC-CFG}\""
-    ifconfig ${NIC-CFG}
-    NIC-DNS=`grep "nic_dns:" ${CONF} | grep -v "^#" | sed "s|nic_dns: ||g" | sed "s|nic_dns:||g"`
-    NIC-GATE=`grep "nic_gateway:" ${CONF} | grep -v "^#" | sed "s|nic_gateway: ||g" | sed "s|nic_gateway:||g"`
+    echo "Running command \"ifconfig ${NICCFG}\""
+    ifconfig ${NICCFG}
+    NICDNS=`grep "nic_dns:" ${CONF} | grep -v "^#" | sed "s|nic_dns: ||g" | sed "s|nic_dns:||g"`
+    NICGATE=`grep "nic_gateway:" ${CONF} | grep -v "^#" | sed "s|nic_gateway: ||g" | sed "s|nic_gateway:||g"`
 
-    echo "nameserver: ${NIC-DNS}" >/etc/resolv.conf
+    echo "nameserver: ${NICDNS}" >/etc/resolv.conf
 
-    echo "Running command \"route add default ${NIC-GATE}\""
-    route add default ${NIC-GATE}
+    echo "Running command \"route add default ${NICGATE}\""
+    route add default ${NICGATE}
   fi
 
   # Now try to fetch the remove file
-  echo "Fetching cfg with: \"curl -o ${INSTALL_CFG} ${PC-CFG}\""
-  curl -o "${INSTALL_CFG}" "${PC-CFG}"
+  echo "Fetching cfg with: \"curl -o ${INSTALL_CFG} ${PCCFG}\""
+  curl -o "${INSTALL_CFG}" "${PCCFG}"
+  if [ "$?" != "0" ]
+  then
+    echo "ERROR: Failed to fetch ${PCCFG}, install aborted"
+    exit 150
+  fi
 
 fi
 
@@ -66,8 +76,12 @@
   
   if [ "${CONFIRM_INS}" != "no" -a "${CONFIRM_INS}" != "NO" ]
   then
-    echo "Press ENTER to begin automated installation. Warning: Data on target disks may be destroyed!"
+    echo "Type in 'install' to begin automated installation. Warning: Data on target disks may be destroyed!"
     read tmp
+    case $tmp in
+       install|INSTALL) ;;
+       *) echo "Install canceled!" ; exit 150 ;;
+    esac
   fi
 
   ${PROGDIR}/pc-sysinstall -c ${INSTALL_CFG}



More information about the Commits mailing list