You are not logged in.

Announcement

[2017.09.08] DeployStudio build v1.7.8 (checksum, release note).
[2016.08.26] DeployStudio build v1.6.19 (release note).
[2013.02.23] DeployStudio last universal build v1.5.17 (release note).

#1 2013-07-30 00:53:37

xserve_admin
Member
Registered: 2009-05-27

AD Bind machine name choices

When using DS for binding with 10.8.4 it works quite well, thank you. So well I am going to dump my own script and use DS from here on in. However, it would be nice if there were a few more "ready made" choices for the Computer ID field. Right now all we have is:

Computer name
Host name

Then there is a line and you can select a script. I'd like to see the following options:

First Ethernet Address
User-defined prefix plus First Ethernet Address

AD is limited to 15 characters and the MAC address takes up 12 of those, so that only leaves room for a three character prefix. Which would be lovely.

Thanks.

P.S. If anyone has a script that already does that, please post it.

Last edited by xserve_admin (2013-07-30 02:29:08)

Offline

#2 2014-06-18 15:17:15

execriez
Member
Registered: 2014-06-18

Re: AD Bind machine name choices

This question was posted a year ago, so maybe I'm a bit late with the reply. Hopefully someone may find it useful.

If you re-encode the base 16 MAC address into base 36, this will take up 10 characters leaving 5 characters for a prefix.
I use a script similar (but not identical) to the one below to rename workstations during re-imaging prior to binding to AD.

It's been knocked together from other peoples examples.
It works for me, however I'm not bothered about having the correct name in the computer database.

If you like, you can test it in Terminal outside of Deploy Studio, and it will print what that workstation would be called.

See below... hope there's no blinding errors...

#! /bin/bash
# ds_GenerateComputerID.sh - Generate a unique workstation name based on MAC address
#
# If used, add the script to the workflow as a Generic Postponed script, and select
# the script in the "Computer ID" section of the AD Directory Binding plugin.
# Workflow order should be Generic script followed by AD Bind plugin.

# Get hex MAC address
if test -n "${DS_PRIMARY_MAC_ADDRESS}"
then
  # We are running in a deploystudio environment
  EN0MAC16=${DS_PRIMARY_MAC_ADDRESS}
else
  # We have called the script outside of Deploy Studio
  # Get the workstation MAC address based on en0's interface
  EN0MAC16=$( /sbin/ifconfig en0 | grep 'ether ' | awk '{print $2}' | head -n 1 )
fi

# Get hex MAC address uppercase without colons
EN0MAC16=$( echo ${EN0MAC16} | tr -d ":" | tr "[a-z]" "[A-Z]")

# Re-encode hex MAC address as base 36
BASE36TBL=($(echo {0..9} {A..Z}))
EN0MAC36=""
for i in $(bc <<< "obase=36; ibase=16; ${EN0MAC16}"); do
  EN0MAC36=${EN0MAC36}${BASE36TBL[$(( 10#${i} ))]}
done

# Left zero pad to 10 characters
EN0MAC36=$( echo ${EN0MAC36} | sed -e :a -e 's/^.\{1,9\}$/0&/;ta' )

# Name for Mac workstation
wks_nam_mac=$( echo "MACX-"${EN0MAC36} | tr "[A-Z]" "[a-z]" )

# Name for Win workstation
wks_nam_win=$( echo "WIN7-"${EN0MAC36} | tr "[A-Z]" "[a-z]" )

if [ "${__OSINSTALL_ENVIRONMENT}" = "1" ]
then
  # Script is running within Deploy Studio Runtime
  # Output Computer ID in format required by the AD Directory Binding plugin
  echo "RuntimeSetBindingComputerID: "${wks_nam_mac}

else
  # Script is running on the workstation

  if test -n "${DS_PRIMARY_MAC_ADDRESS}"
  then
    # We are running in a deploystudio environment
    # Set the workstation name
    /usr/sbin/scutil --set ComputerName ${wks_nam_mac}
    /usr/sbin/scutil --set HostName ${wks_nam_mac}
    /usr/sbin/scutil --set LocalHostName ${wks_nam_mac}
    /usr/sbin/systemsetup -setcomputername ${wks_nam_mac}
    /usr/sbin/systemsetup -setlocalsubnetname ${wks_nam_mac}

  else
    # We have called the script outside of Deploy Studio
    echo "DEBUG: workstation would be named as "${wks_nam_mac}

  fi
fi

Offline

Board footer

Powered by FluxBB