#!/bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH ################################################################################ #Values: # #wireless: the SSID of the wireless network you want the machine to join #prefix: the junk that goes before the serial number in the computer name #adadmin: AD credentials of user that can add objects to AD and whatnot # #adadminpw: AD password of that ad admin user you just specified # #addomain: the AD domain you're joining # #odip: IP of your OD master #odserverfqdn: the full qualified domain name of your OD server # ################################################################################ wireless= prefix= adadmin= adadminpw= addomain= opip= odserverfqdn= ############################################## networksetup -setairportnetwork en1 $wireless sleep 10 serial=` /usr/sbin/system_profiler SPHardwareDataType | grep "Serial Number (system): " | cut -c 31-41` computerid=$prefix$serial scutil --set ComputerName $computerid scutil --set LocalHostName $computerid scutil --set HostName $computerid sleep 10 #-------------------------------------- #Bind to AD dsconfigad -mobile disable -mobileconfirm disable -localhome disable -useuncpath enable -protocol afp dsconfigad -f -domain $addomain -u $adadmin -p $adadminpw -status defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" Active dscl /Search -append / CSPSearchPath "/Active Directory/All Domains" dscl /Search -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath dscl /Search/Contacts -append / CSPSearchPath "/Active Directory/All Domains" dscl /Search/Contacts -create / SearchPolicy dsAttrTypeStandard:CSPSearchPath killall DirectoryService #-------------------------------------- # Get Domain via reverse lookup on server IP address Domain=`host $odip | cut -d " " -f 5 | sed s/.$//` #-------------------------------------- #Remove all previous LDAP Info LDAP=`dscl localhost -list / | grep LDAP` if ! [[ $LDAP = '' ]] ; then DSServers=`dscl localhost -list /LDAPv3` for server in $DSServers do dsconfigldap -r $server done fi #-------------------------------------- #Remove Directory Service Settings and restart DS if [ -e "/Library/Preferences/DirectoryService/*.*" ] ; then rm /Library/Preferences/DirectoryService/*.* fi if [ -e "/Library/Preferences/edu.mit.kerberos" ] ; then rm /Library/Preferences/edu.mit.kerberos fi #-------------------------------------- #Create LDAP entry for School OD Server #Add LDAP Binding dsconfigldap -a $odserverfdqn #Create Search Paths for Authentication and Contacts dscl /Search -create / SearchPolicy CSPSearchPath dscl /Search/Contacts -create / SearchPolicy CSPSearchPath #Append Open Dir config to the Search Path dscl /Search -append / CSPSearchPath /LDAPv3/$odserverfdqn dscl /Search/Contacts -append / CSPSearchPath /LDAPv3/$odserverfdqn killall DirectoryService killall WindowServer