[PC-BSD Commits] r21882 - pcbsd/current/src-sh/pc-thinclient/resources/scripts

svn at pcbsd.org svn at pcbsd.org
Sat Mar 16 06:36:35 PDT 2013


Author: kris
Date: 2013-03-16 13:36:35 +0000 (Sat, 16 Mar 2013)
New Revision: 21882

Modified:
   pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcsinstall.sh
   pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcslogin.sh
Log:

Add support to pc-thinclient for auto installing based upon a clients
mac address. I thought I had put this in earlier, but must have missed it.

To use, create the file /home/thinclient/installscripts/${MAC}.cfg

A client which boots with the same ${MAC} address will be automatically
installed using the said config. 



Modified: pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcsinstall.sh
===================================================================
--- pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcsinstall.sh	2013-03-16 09:22:41 UTC (rev 21881)
+++ pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcsinstall.sh	2013-03-16 13:36:35 UTC (rev 21882)
@@ -23,16 +23,68 @@
   esac
 }
 
-# Detect if we have an unattended install to do
+# Function which determines if a nic is active / up
+is_nic_active()
+{
+  ifconfig ${1} | grep -q "status: active" 2>/dev/null
+  if [ $? -eq 0 ] ; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+# Find the active nic
+get_active_nic()
+{
+  for i in $(ifconfig -l); do
+    case "${i%%[0-9]*}" in
+      lo|fwe|fwip|plip|pfsync|pflog|tun)
+      continue
+      ;;
+    esac
+    is_nic_active "${i}"
+    if [ $? -eq 0 ] ; then
+       echo "$i"
+       return 0
+    fi
+  done
+  return 1
+}
+
+# Get the mac address of a target NIC
+get_nic_mac()
+{
+  FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`"
+  echo $FOUNDMAC
+}
+
+# Check for MAC address config file
+NIC=$(get_active_nic)
+MAC=$(get_nic_mac "$NIC")
+
+# Detect auto-install scripts
+ASCRIPT=""
 if [ -e "/installscripts/unattended.cfg" ] ; then
+   ASCRIPT="/installscripts/unattended.cfg"
+fi
+if [ -e "/installscripts/${MAC}.cfg" ] ; then
+   ASCRIPT="/installscripts/${MAC}.cfg"
+fi
 
-  echo "Unattended installation will begin in 30 seconds. Press Enter to abort and go to menu."
+# Are we doing an automated install?
+if [ -n "${ASCRIPT}" ] ; then
+
+  echo "Preparing to install using: ${ASCRIPT}"
+  echo "Will automatically continue in 30 seconds."
+  echo "Press ENTER to cancel"
+
   read -t30s ans
   if [ $? -eq 1 ] ; then
-    pc-sysinstall -c /installscripts/unattended.cfg
+    pc-sysinstall -c ${ASCRIPT}
     if [ $? -eq 0 ] ; then
       echo "Install finished! Shutting down system now!"
-      shutdown -p now
+      halt -p
       exit 0
     fi
 
@@ -42,7 +94,6 @@
   fi
 fi
 
-
 # Run the interactive menu
 while :
 do

Modified: pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcslogin.sh
===================================================================
--- pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcslogin.sh	2013-03-16 09:22:41 UTC (rev 21881)
+++ pcbsd/current/src-sh/pc-thinclient/resources/scripts/tcslogin.sh	2013-03-16 13:36:35 UTC (rev 21882)
@@ -10,6 +10,7 @@
 # Check if we are running as an install server
 if [ -e "/etc/installserver" ] ; then
   /etc/scripts/tcsinstall.sh
+  halt -p
 fi
 
 # Restart moused



More information about the Commits mailing list