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

svn at pcbsd.org svn at pcbsd.org
Tue Dec 1 11:44:42 PST 2009


Author: kris
Date: 2009-12-01 11:44:42 -0800 (Tue, 01 Dec 2009)
New Revision: 5178

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

added support for timeZone and NTP settings to pc-sysinstall



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh	2009-12-01 19:27:03 UTC (rev 5177)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-localize.sh	2009-12-01 19:44:42 UTC (rev 5178)
@@ -238,7 +238,33 @@
 
 };
 
+# Function which sets the timezone on the system
+set_timezone()
+{
+  TZONE="$1"
+  cp ${FSMNT}/usr/share/zoneinfo/${TZONE} ${FSMNT}/etc/localtime
+};
 
+# Function which enables / disables NTP
+set_ntp()
+{
+  ENABLED="$1"
+  if [ "$ENABLED" = "yes" -o "${ENABLED}" = "YES" ]
+  then
+    cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
+    if [ "$?" != "0" ]
+    then
+      echo 'ntpd_enable="YES"' >>${FSMNT}/etc/rc.conf
+    fi
+  else
+    cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null
+    if [ "$?" != "0" ]
+    then
+      sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf
+    fi
+  fi
+};
+
 # Starts checking for localization directives
 run_localize()
 {
@@ -284,6 +310,22 @@
       get_value_from_string "$line"
       localize_key_variant "$VAL"
     fi
+
+    # Check if we need to set a timezone
+    echo $line | grep "^timeZone=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      get_value_from_string "$line"
+      set_timezone "$VAL"
+    fi
+
+    # Check if we need to set a timezone
+    echo $line | grep "^enableNTP=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      get_value_from_string "$line"
+      set_ntp "$VAL"
+    fi
   done <${CFGF}
 
 };



More information about the Commits mailing list