Skip to content

Instantly share code, notes, and snippets.

@MelvinStans
Created February 25, 2019 08:18
Show Gist options
  • Save MelvinStans/812d419bd30e0c0e703d599fcf525c2e to your computer and use it in GitHub Desktop.
Save MelvinStans/812d419bd30e0c0e703d599fcf525c2e to your computer and use it in GitHub Desktop.
#!/bin/sh
##########################################################################################
# Create time date stamped log
##########################################################################################
logFile="/private/var/log/OurCompany.log"
log () {
/bin/echo $1
/bin/echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}
log "-----"
log "Begin script resetMacNetwork.sh"
log "Adjust Network Locations to correctly add network ports"
sleep 5
##########################################################################################
# Create a temporarily Network location and recreate the Automatic location.
##########################################################################################
networksetup -createlocation TempLoc populate
sleep 5
networksetup -switchtolocation TempLoc
sleep 2
networksetup -deletelocation Automatic
sleep 2
networksetup -createlocation Automatic populate
sleep 5
networksetup -switchtolocation Automatic
sleep 5
networksetup -deletelocation TempLoc
log “Network Location Setup Completed.”
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment