Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. usage()
  2. {
  3. echo "usage: sysinfo_page [[[-f file ] [-i]] | [-h]]"
  4. }
  5.  
  6. #### Main
  7.  
  8. while [[ $# -gt 0 ]]
  9. do
  10. key="$1"
  11.  
  12. case $key in
  13. -ad | --domain ) domain="$2"
  14. shift # past argument
  15. shift # past value
  16. ;;
  17. -u | --username ) username="$2"
  18. shift # past argument
  19. shift # past value
  20. ;;
  21. -p | --password ) password="$2"
  22. shift # past argument
  23. shift # past value
  24. ;;
  25. --default)
  26. DEFAULT=YES
  27. shift # past argument
  28. ;;
  29. *) # unknown option
  30. shift # past argument
  31. ;;
  32. esac
  33. done
  34.  
  35. ## More variables - No need to edit
  36.  
  37. olddomain=$( dsconfigad -show | awk '/Active Directory Domain/{print $NF}' )
  38. computername=$( scutil --get ComputerName )
  39. adcomputerid=$( echo "${computername}" | tr [:lower:] [:upper:] )
  40. prefix="${adcomputerid:0:6}"
  41.  
  42. echo "Using computer name '${adcomputerid}'..."
  43. echo ""
  44.  
  45.  
  46. ## Unbind if already bound
  47.  
  48.  
  49. # If the domain is correct
  50. if [[ "${olddomain}" == "${domain}" ]]; then
  51. # Check the id of a user
  52. id -u "${username}" > /dev/null 2>&1
  53.  
  54.  
  55. # If the check was successful...
  56. if [[ $? == 0 ]]; then
  57. echo -n "This machine is bound to AD. Unbinding..."
  58.  
  59.  
  60. # Unbind from AD
  61. dsconfigad -remove -force -u "${username}" -p "${password}"
  62.  
  63.  
  64. # Re-check the id of a user
  65. id -u "${username}" > /dev/null 2>&1
  66.  
  67. # If the check was successful...
  68. if [[ $? == 0 ]]; then
  69. echo "Failed (Error code: 1)"
  70. exit 1
  71. else
  72. echo "Success"
  73. echo ""
  74. fi
  75. fi
  76. fi
  77.  
  78.  
  79. ## Perform bind
  80. echo "binding to domain ${domain}"
  81. dsconfigad -add "${domain}" -username "${username}" -password "${password}" \
  82. -computer "${adcomputerid}" -useuncpath enable -mobile enable \
  83. -mobileconfirm disable -shell /bin/bash -force \
  84.  
  85. ## -ou "${ou}"
  86.  
  87. ## Set show input menu in login window to TRUE
  88. echo "Setting the login window"
  89. defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool TRUE
  90.  
  91. ## Set login window to use Name & Password
  92. echo "Setting login by user name and password"
  93. defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool true
  94.  
  95. ## Set Login Message
  96. echo "Setting login message"
  97. sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Property of Nomensa Ltd"
  98.  
  99. ## Set Nomensa Wallpaper
  100. echo "Set Nomensa Wallpaper"
  101. osascript -e 'tell application "Finder" to set desktop picture to "/Users/admin/Desktop/2560x1440.png" as POSIX file'
  102.  
  103. ## Munki Config
  104. echo "setting munki config"
  105. defaults write /Library/Preferences/ManagedInstalls.plist ClientIdentifier ${adcomputerid}
  106. defaults write /Library/Preferences/ManagedInstalls.plist SoftwareRepoURL https://munki.intranet.nomensa.com/munki_repo
  107.  
  108. ## Install Fonts
  109. ## Check if we need to use ~ or not
  110.  
  111. ## cd ~/Library/Fonts && { curl -O 'https://github.com/FrankHassanabad/ResumeBuilder/blob/master/fonts/src/main/resources/frankhassanabad/com/github/windowsfonts/BRLNSR.TTF' ; cd -; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement