Guest User

Untitled

a guest
Dec 4th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3.  
  4.  
  5. # Only root should run this
  6. #
  7. if [ $USER != 'root' ]
  8. then
  9. echo Only root may use this command\!
  10. echo Prefix your command line with '"'sudo '"'
  11. echo Exiting...
  12. echo ' '
  13. exit
  14. fi
  15.  
  16. # Explain what is going to happen
  17. #
  18. echo ' '
  19. echo This script will join the system to UMN.DS. The computer
  20. echo account must exist in Active Directory before this script is run.
  21.  
  22. NUMBER=`system_profiler | grep "Serial Number (system):" | awk '{print $4}' | sed 's/[:]//g' | awk '{ print substr( $0, length($0) - 7, length($0) ) }'`
  23. AD_COMPUTERNAME='L-X8-'$NUMBER
  24.  
  25. echo $AD_COMPUTERNAME
  26.  
  27. AD_ADMINUSER="administrator"
  28. AD_PASSWORD="hello4world"
  29. AD_OU="OU=MA,OU=Ugs,OU=Skola,OU=Computers,OU=UK,DC=udn,DC=ds"
  30.  
  31. scutil --set ComputerName $AD_COMPUTERNAME
  32. scutil --set LocalHostName $AD_COMPUTERNAME
  33. scutil --set HostName $AD_COMPUTERNAME
  34.  
  35. # Join computer to Active Directory
  36. #
  37. # We skip the flags "-alldomains enable -localhome enable" since they are
  38. # enabled by default.
  39. #
  40. dsconfigad -add udn.ds -username $AD_ADMINUSER -password $AD_PASSWORD -computer $AD_COMPUTERNAME -ou $AD_OU -localuser lokaladmin -force
  41. dsconfigad -mobile enable -mobileconfirm disable -useuncpath enable
  42.  
  43. sleep 5
  44.  
  45. exit 0
  46.  
  47. #
  48. ##[The End]##
Add Comment
Please, Sign In to add comment