Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while :; do # Loop until valid input is entered or Cancel is pressed.
- user=$(osascript -e 'Tell application "System Events" to display dialog "Enter the network user name:" default answer ""' -e 'text returned of result' 2>/dev/null)
- if (( $? )); then exit 1; fi # Abort, if user pressed Cancel.
- user=$(echo -n "$user" | sed 's/^ *//' | sed 's/ *$//') # Trim leading and trailing whitespace.
- if [[ -z "$user" ]]; then
- # The user left the project name blank.
- osascript -e 'Tell application "System Events" to display alert "You must enter a user name; please try again." as warning' >/dev/null
- # Continue loop to prompt again.
- else
- # Valid input: exit loop and continue.
- break
- fi
- done
- while :; do # Loop until valid input is entered or Cancel is pressed.
- netpass=$(osascript -e 'Tell application "System Events" to display dialog "Enter the network password:" default answer ""' -e 'text returned of result' 2>/dev/null)
- if (( $? )); then exit 1; fi # Abort, if user pressed Cancel.
- netpass=$(echo -n "$netpass" | sed 's/^ *//' | sed 's/ *$//') # Trim leading and trailing whitespace.
- if [[ -z "$netpass" ]]; then
- # The user left the project name blank.
- osascript -e 'Tell application "System Events" to display alert "You must enter a password; please try again." as warning' >/dev/null
- # Continue loop to prompt again.
- else
- # Valid input: exit loop and continue.
- break
- fi
- done
- MACNAME=$(scutil --get ComputerName)
- sudo dsconfigad -add DOMAIN
- -username $user
- -password $netpass
- -computer $MACNAME
- -mobile disable
- -mobileconfirm disable
- -localhome enable
- -useuncpath enable
- -shell /bin/bash
- -ou OU=Macs,CN=Computers,DC=corp,DC=DOMAIN,DC=net
- -force
- -localpassword LOCALPASS
- -groups "GROUPS"
- #sudo rm -- "$0"
- osascript -e 'Tell application "System Events" to display dialog "Enter the network password:" with hidden answer default answer ""' -e 'text returned of result' 2>/dev/null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement