/
SetTimeCentral.sh
41 lines (29 loc) · 1.31 KB
/
SetTimeCentral.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
# This script must be run as root or via Jamf.
# Use "/usr/sbin/systemsetup -listtimezones" to see a list of available list time zones.
# TimeZone variable should be filled with the TimeZone information (ie: America/Chicago, America/New_York )
# TimeServer variable should be filled with the TimeServer information (ie: time.apple.com )
TimeZone="America/Chicago"
TimeServer="time.apple.com"
# Disable network time
systemsetup -setusingnetworktime off
# Set an initial time zone
systemsetup -settimezone "$TimeZone"
# Set specific time server
systemsetup -setnetworktimeserver "$TimeServer"
# Unload locationd
launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
# Write enabled value to locationd plist
defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd LocationServicesEnabled -int 1
# Fix Permissions for the locationd folder
chown -R _locationd:_locationd /var/db/locationd
# Reload locationd
launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
# set time zone automatically using current location
defaults write /Library/Preferences/com.apple.timezone.auto Active -bool true
# Re-enable network time
systemsetup -setusingnetworktime on
# Detect the timezone
systemsetup -gettimezone
# Get the time from time server
systemsetup -getnetworktimeserver