So with some help I've got a script that checks the date and if the date is before 2015 it then sets the date to 2015 then turns off wireless then turns on wireless and then sets the time back to network time.
I'm now trying to get this check to happen at startup via a launch daemon and I cannot seem to get it working Getting an Error 13. Im storing the script in the /Library/Application Support/JAMF folder.
Would also be great to have this be triggered by a wake from sleep as well.
Is it possible that I have the permissions wrong? root is the owner of both files and both are set to 644.
The reason for this is our wireless controller issues a certificate that was created in 2012 and when a mac runs totally out of power it resets to a date before 2012 and then cannot rejoin the network until the date gets back within the certificate period (2012-2025). This script fixes this issue but I just can't seem to get the script called correctly.
Any help will be greatly appreciated!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.pps.setdateandtime</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/Library/Application Support/JAMF/setdateandtime.sh</string>
</array>
</dict>
</plist>
This is the script:
#!/bin/bash
macdate=$(date +"%Y%m%d")
comparison="20150101"
if [ $comparison -ge $macdate ]; then
date 0102010115
networksetup -setairportpower en1 off
networksetup -setairportpower en1 on
sleep 15
ntpdate -u time.apple.com
fi