Skip to main content
Question

ComputerName change script.

  • August 26, 2011
  • 1 reply
  • 0 views

Forum|alt.badge.img+12

I set the computer name in several places and our naming convention includes
the owner's name etc. This poses a problem for things like marriages etc. I
whipped this up this afternoon because a bunch of machines were incorrectly
named. Thought someone might find it useful.

#!/bin/bash

main() {

read -r -p "What should I change the computer name to? " new_name

hostname "${new_name}"

scutil --set ComputerName "${new_name}"

scutil --set LocalHostName "${new_name}"

printf "%s " "AFPSERVER=-NO-" "AUTHSERVER=-NO" "TIMESYNC=-YES-"
"QTSSERVER=-NO-" "HOSTNAME=-${new_name}-" > /etc/hostconfig

printf "%s " "Sending new info. to Casper Database."

jamf recon

printf "%s " "Please restart the machine and then bind to AD via Casper
policy."

exit 0
}

while read -r -p "Have you unbound the machine from AD and is the old
account deleted? (y/n) " input; do

case "${input}" in

[Yy]) main ;;

[Nn]) printf "%s " "Please do so and wait the 15 minutes for
replication"; exit 1 ;;

*) printf " %s " "Answer the question please..." ;;

esac

done

Ryan M. Manly
Glenbrook High Schools

1 reply

Forum|alt.badge.img+12
  • Author
  • Contributor
  • 312 replies
  • August 26, 2011

Silly mistake here

"HOSTNAME=-${new_name}-"

should be

"HOSTNAME=${new_name}"

Ryan M. Manly
Glenbrook High Schools


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings