Mac Deployment One Click Script

We don't have Casper in our environment, so everything is still quite manual when deploying a mac. One day I was so tired of endless click to join a mac to AD. then I start working on mac deployment.

The main script for macs to join AD is from Vaughn Miller, https://github.com/vmiller/vmiller_scripts/tree/master/Interactive_AD_Bind

For my script, you can download from here:

https://github.com/ruiqiu/mac_deployment

What does this one click script do:

  1. Run as root (if not, will prompt you to do so) (Q);
  2. Ask you for computer name, username, and password to join AD (john.sh);
  3. Enable mobile account (john.sh);
  4. Add domain groups to local admin group (john1.sh);
  5. Install Mac SCCM client (Q);
  6. Install ESET Anti-virus software  (Q);
  7. Ask for reboot (Q)

Some Q & A

  • What is the file Q?
    Q is an Unix Executable File, there's no file extension for it, but when you double click, it will run.
  • How to create Unix Executable File on Mac?
    Open your terminal and type, chmod +x file_name
  • What does path=$( cd “$( dirname “${BASH_SOURCE[0]}” )” && pwd ) mean?
    Find the absolute path of the current script is running location. You may think path = pwd should work, but it didn't.
    I also tried using path = ‘dirname $0', not working neither
  • When running a shell script inside an unix executable file, can I just use sudo sh path/join.sh?
    I tried and it failed. because if there are some spaces in the path, it will said file does not exist. using ${path} can include the spaces inside the path.
  • What if there are some spaces in my network admin group? For example, “AD\* Admin HD”?
    In this case, we need to use AD\\*\ Admin\ HD ( add “\” before the space, and if there is an actual “\”, use double “\\”. and if you have more than one admin group needs to add, use “,” to combine.

 

Leave a Comment