ComputerName change script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-26-2011 02:34 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-26-2011 03:46 PM
Silly mistake here
"HOSTNAME=-${new_name}-"
should be
"HOSTNAME=${new_name}"
Ryan M. Manly
Glenbrook High Schools
