Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. while :; do # Loop until valid input is entered or Cancel is pressed.
  4. 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)
  5. if (( $? )); then exit 1; fi # Abort, if user pressed Cancel.
  6. user=$(echo -n "$user" | sed 's/^ *//' | sed 's/ *$//') # Trim leading and trailing whitespace.
  7. if [[ -z "$user" ]]; then
  8. # The user left the project name blank.
  9. osascript -e 'Tell application "System Events" to display alert "You must enter a user name; please try again." as warning' >/dev/null
  10. # Continue loop to prompt again.
  11. else
  12. # Valid input: exit loop and continue.
  13. break
  14. fi
  15. done
  16.  
  17. while :; do # Loop until valid input is entered or Cancel is pressed.
  18. netpass=$(osascript -e 'Tell application "System Events" to display dialog "Enter the network password:" default answer ""' -e 'text returned of result' 2>/dev/null)
  19. if (( $? )); then exit 1; fi # Abort, if user pressed Cancel.
  20. netpass=$(echo -n "$netpass" | sed 's/^ *//' | sed 's/ *$//') # Trim leading and trailing whitespace.
  21. if [[ -z "$netpass" ]]; then
  22. # The user left the project name blank.
  23. osascript -e 'Tell application "System Events" to display alert "You must enter a password; please try again." as warning' >/dev/null
  24. # Continue loop to prompt again.
  25. else
  26. # Valid input: exit loop and continue.
  27. break
  28. fi
  29. done
  30.  
  31. MACNAME=$(scutil --get ComputerName)
  32.  
  33. sudo dsconfigad -add DOMAIN
  34. -username $user
  35. -password $netpass
  36. -computer $MACNAME
  37. -mobile disable
  38. -mobileconfirm disable
  39. -localhome enable
  40. -useuncpath enable
  41. -shell /bin/bash
  42. -ou OU=Macs,CN=Computers,DC=corp,DC=DOMAIN,DC=net
  43. -force
  44. -localpassword LOCALPASS
  45. -groups "GROUPS"
  46.  
  47. #sudo rm -- "$0"
  48.  
  49. 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