In the interest of sharing what we’ve done, I use the following in a first boot script:
[code]
###########################
# Configure the Time Zone #
###########################
# link the localtime file in /private/etc/ to your time zone /usr/share/zoneinfo:
/bin/ln -s -f /usr/share/zoneinfo/US/Eastern /private/etc/localtime
# Configure the GlobalPreferences file with the exact city you live in:
# clear out the array in case default info is hanging around:
/usr/libexec/PlistBuddy -c “Delete :com.apple.TimeZonePref.Last_Selected_City” /Library/Preferences/.GlobalPreferences.plist
# recreate the array for selected city:
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City array” /Library/Preferences/.GlobalPreferences.plist
#################################
# Set network time server prefs #
#################################
# There are three parts to configuring network time services:
# 1) set the ntp server
# 2) turn on autosync in the legacy /private/etc/hostconfig file (this file will be going away in later versions of Mac OS X)
# 3) set the ntpd launch daemon to “enabled”
###
# set the network time server:
/bin/echo “server time.domain.edu” > /private/etc/ntp.conf
# make a backup of the hostconfig file before editing:
/bin/cp /private/etc/hostconfig /private/tmp/hostconfig.backup
# now set the hostconfig settings to autosync with the network time:
/usr/bin/sed ‘s/^TIMESYNC=-NO-$/TIMESYNC=-YES-/’ /private/tmp/hostconfig.backup > /private/etc/hostconfig
# now delete the key which disables the ntpd daemon and keeps it from running at boot:
/usr/libexec/PlistBuddy -c “Delete :Disabled” /System/Library/LaunchDaemons/org.ntp.ntpd.plist
# and now kickstart the service incase its not already loaded:
/bin/launchctl load /System/Library/LaunchDaemons/org.ntp.ntpd.plist
[/code]
– You could probably bake most (if not all) of that into a CustomPKG and place it into the image at InstaDMG runtime.
– But if you’re going to run it at first startup, you can use systemsetup to set the time zone, but systemsetup won’t work on non-startup disks. See the “timezone” entries in the systemsetup man page.
– And if you’re going to run it at first startup, systemsetup can also set up NTP for you. Se the “timeserver” entries in the systemsetup man page.
The systemsetup man page is [url=http://developer.apple.com/documentation/Darwin/Reference/Manpages/man8/systemsetup.8.html]here[/url] or available in a Terminal near you.
You’ve essentially done 95% of the work to get your modifications working at InstaDMG runtime, but you’re running it at first boot. However, if you’ve already vetted everything the above suggestions are probably busywork.
Maybe I’m a noob, but could please somebody explain these lines. What does each line refer to?
String 0-2 has numbers and 5 and 7 & 6 and 8 are duplicates.
I’m trying to set up an image localized to Danish.
as an example of putting it in a PKG here’s the NTP stuff from our current custom PKG:
[code]timezone=’Europe/London’
timeserver=xxxxx
ln -sf “/usr/share/zoneinfo/${timezone}” “$3/etc/localtime” # Set timezone by creating a symbolic link
echo “server ${timeserver} iburst” > “$3/private/etc/ntp.conf” # Create an appropriate ntpd.conf file
sed -i .bak ‘s/TIMESYNC=-NO-/TIMESYNC=-YES-/’ “$3/etc/hostconfig” # Update the hostconfig file to use NTP
[/code]
as an aside – does anyone know if that iburst setting in the ntp.conf is still valid/useful
If these scripts are being run as first boot scripts it is much easier imho to use the systemsetup command to configure things like NTP or SSH. As opposed to writing scripts that rely on creating symbolic links to the appropriate Time Zone or editing plist files. The command is easy to use and will accomplish setting NTP settings. I will post up my first boot script once I get back to my work computer. In the meantime read about the command here:
Also, as Patrick mentioned above, systemsetup can’t be run on on a volume you aren’t booted off of. But if you are writing scripts to run on first boot anyway the systemsetup command is much easier to use and requires less code.
Here are my scripts. One is the postflight script that is run during the InstaDMG creation process that creates the Launchd item and installs the script. The other is the script that runs on startup. I created these after getting lots of good info and tips from these forums 🙂 Feel free to modify them.
Postflight script that installs the script and the Launchd item:
[code]
#!/bin/sh
# Install startup settings Launchd item and corresponding script.
# System startup script that should be a Launchd startup script, that deletes itself and the launchd item after completion.
# This script turns on NTP and sets NTP server. Also sets Time Zone. Enables ARD and SSH.
# Define ‘kickstart’ and ‘systemsetup’ variables, built in OS X script that activates and sets options for ARD.
# Set options and activate ARD for only our admin user with all privelages. Turn on VNC and set password to yoursupersecurepasswordhere.
# First we have to define specified users with ARD privelages in a separate command. Replace youradminusehere wih your Administrators short-name. More options for kickstart can be found here: http://support.apple.com/kb/HT2370
#### Begin Time and Network Services Configuration ####
# Replace ‘America/New_York’ with your time zone. To list time zones in terminal run: sysemsetup -listtimezones. Set your time server by replacing some.timeserver.here.
$systemsetup -settimezone America/New_York -setusingnetworktime on -setnetworktimeserver some.timeserver.here
# Activate WakeOnLAN.
$systemsetup -setwakeonnetworkaccess on
# Activate SSH.
$systemsetup -setremotelogin on
#### End Time and Network Services Configuration ####
Thanks for sharing your script! It’s really useful with the detailed comments. Do you happen to know how to also change keyboard layout and how to change the Region settings?
[url=http://simulationcreditauto.net/][color=#E7E7E7][u]simulation credit auto[/u][/color][/url]
😀 your release is really great. Thanks eric_csm so much
Comments are closed