- This topic has 25 replies, 10 voices, and was last updated 15 years, 10 months ago by
truecolor.
-
AuthorPosts
-
January 13, 2009 at 4:11 pm #375122
typofonic
ParticipantThanks for all of your help. I managed to set the TimeZone and NTP!
Now the only thing missing is changing the Format in the International pane of System Preferences to Danish… Hmm
– Anders
March 31, 2009 at 7:21 pm #375862aaronwyatt
ParticipantIn 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# add lat, long, zone, country, city, etc.:
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:0 string 42.333336” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:1 string -71.083336” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:2 string 6” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:3 string ‘US/Eastern'” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:4 string ‘US'” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:5 string Boston” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:6 string U.S.A.” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:7 string Boston” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:8 string U.S.A.” /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]April 1, 2009 at 4:46 pm #375872typofonic
ParticipantWow, Aaron!
Thanks a lot for sharing. Will try it out!
– Anders
April 3, 2009 at 4:12 pm #375917Patrick Fergus
Participantaaronwyatt,
Nice script. A couple quick comments:
– 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.
– Patrick
May 24, 2009 at 11:40 am #376278typofonic
Participant[QUOTE][u]Quote by: aaronwyatt[/u][p]
# add lat, long, zone, country, city, etc.:
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:0 string 42.333336” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:1 string -71.083336” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:2 string 6” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:3 string ‘US/Eastern'” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:4 string ‘US'” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:5 string Boston” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:6 string U.S.A.” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:7 string Boston” /Library/Preferences/.GlobalPreferences.plist
/usr/libexec/PlistBuddy -c “Add :com.apple.TimeZonePref.Last_Selected_City:8 string U.S.A.” /Library/Preferences/.GlobalPreferences.plist
[/code][/p][/QUOTE]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.
Any ideas?
May 25, 2009 at 4:48 pm #376285alantrewartha
Participantas an example of putting it in a PKG here’s the NTP stuff from our current custom PKG:
[code]timezone=’Europe/London’
timeserver=xxxxxln -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
May 29, 2009 at 11:22 pm #376338walt
ParticipantIf 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:
[url]http://developer.apple.com/documentation/Darwin/Reference/Manpages/man8/systemsetup.8.html[/url]\
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.
June 1, 2009 at 2:15 pm #376343walt
ParticipantHere 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.
# Script by Walter Meyer
# Declare ‘defaults’and ‘PlistBuddy’.
defaults=”/usr/bin/defaults”
PlistBuddy=”/usr/libexec/PlistBuddy”# Define directory variables.
PKG_DIR=”$1/Contents/Resources”
SCRIPTS_DIR=”$3/Library/Scripts”
LAUNCHD_DIR=”$3/Library/LaunchDaemons”# Create scripts directory.
mkdir “${SCRIPTS_DIR}”
# Copy startupssettings.sh script to the scripts directory.
cp “${PKG_DIR}/startupsettings.sh” “${SCRIPTS_DIR}”
# Install Launchd item to /Library/LaunchDaemons. Change com.yourcompany.startupsettings to your orginization.
$defaults write “${LAUNCHD_DIR}/com.yourcompany.startupsettings” Label com.yourcompany.startupsettings
$defaults write “${LAUNCHD_DIR}/com.yourcompany.startupsettings” ProgramArguments -array
$PlistBuddy -c “Add :ProgramArguments:Item\ 1 string /Library/Scripts/startupsettings.sh” “${LAUNCHD_DIR}/com.yourcompany.startupsettings.plist”
$defaults write “${LAUNCHD_DIR}/com.yourcompany.startupsettings” RunAtLoad -bool YES# Give Launchd item correct permissions.
chown root:wheel “${LAUNCHD_DIR}/com.yourcompany.startupsettings.plist”
chmod 644 “${LAUNCHD_DIR}/com.yourcompany.startupsettings.plist”exit 0
[/code]
StartupSettings.sh script:
[code]
#!/bin/sh# 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.
# Script by Walter Meyer
kickstart=”/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart”
systemsetup=”/usr/sbin/systemsetup”#### Begin ARD Configuration ####
# 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
$kickstart -configure -users youradminuserhere -access -on -privs -all
# The next command configures the other ARD options.
$kickstart -activate -configure -allowAccessFor -specifiedUsers -clientopts -setmenuextra -menuextra yes -setvnclegacy -vnclegacy yes -setvncpw -vncpw yoursupersecurepasswordhere
#### End ARD Configuration ####
#### 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 ####
# Delete the script and the launchd item.
rm /Library/LaunchDaemons/com.yourcompany.startupsettings.plist
srm “$0”
[/code]June 1, 2009 at 2:51 pm #376344typofonic
ParticipantHey Walt,
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?
/ Anders
June 8, 2009 at 12:52 am #376409truecolor
Participant[url=http://simulationcreditauto.net/][color=#E7E7E7][u]simulation credit auto[/u][/color][/url]
😀 your release is really great. Thanks eric_csm so much -
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed