Script: Set Network Time Server

terminalMac OS X provides a one-stop command for viewing and setting several OS configuration items.  The systemsetup command is found at /usr/sbin/systemsetup.

Running the command:

man systemsetup

in the Terminal application will return a full listing of the options available in this command.  This script uses the systemsetup command to configure a target system to use a specified network time server.  The script, as written, is intended for use with The Casper Suite.  Replacing $4 with a static value or using another method of passing a value would be necessary if you are not using The Casper Suite.

#!/bin/bash
##### HEADER BEGINS #####
# scr_sys_setNTP.bash
#
# Created 20090627 by Miles A. Leacy IV
# miles.leacy@themacadmin.com
# Modified 20090627 by Miles A. Leacy IV
# Copyright 2009 Miles A. Leacy IV
#
# This script may be copied and distributed freely as long as this header
# remains intact.
#
# This script is provided “as is”.  The author offers no warranty or
# guarantee of any kind.
# Use of this script is at your own risk.  The author takes no responsibility
# for loss of use,
# loss of data, loss of job, loss of socks, the onset of armageddon, or any
# other negative effects.
#
# Test thoroughly in a lab environment before use on production systems.
# When you think it’s ok, test again.  When you’re certain it’s ok, test
# twice more.
#
# This script sets a Mac OS X system to use a network time server specified
# by the value passed in the $4 parameter by the Casper Suite.
# Run as an “at reboot” script when imaging with Casper, making sure to type
# double-check the serial in the script parameters before imaging.
#
##### HEADER ENDS #####
systemsetup -setusingnetworktime on -setnetworktimeserver $4
#!/bin/bash

##### HEADER BEGINS #####
# scr_sys_setNTP.bash
#
# Created 20090627 by Miles A. Leacy IV
# miles.leacy@themacadmin.com
# Modified 20090627 by Miles A. Leacy IV
# Copyright 2009 Miles A. Leacy IV
#
# This script may be copied and distributed freely as long as this header
# remains intact.
#
# This script is provided "as is".  The author offers no warranty or
# guarantee of any kind.
# Use of this script is at your own risk.  The author takes no responsibility
# for loss of use,
# loss of data, loss of job, loss of socks, the onset of armageddon, or any
# other negative effects.
#
# Test thoroughly in a lab environment before use on production systems.
# When you think it's ok, test again.  When you're certain it's ok, test
# twice more.
#
# This script sets a Mac OS X system to use a network time server specified
# by the value passed in the $4 parameter by the Casper Suite.
# Run as an "at reboot" script when imaging with Casper, making sure to type
# double-check the serial in the script parameters before imaging.
#
##### HEADER ENDS #####

systemsetup -setusingnetworktime on -setnetworktimeserver $4

exit 0

One thought on “Script: Set Network Time Server”

  1. Hi,

    i would like to thank you for this post – somehow i missed that command (systemsetup) until today while it looks very promising for ard-scripts.

    Thumbs up for your current posts which are all interessting … would be great to see if you continue your work in this blog.

    Greetings
    fidel

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s