- This topic has 6 replies, 5 voices, and was last updated 16 years, 5 months ago by
knowmad.
-
AuthorPosts
-
October 24, 2008 at 6:49 pm #374548
trondah
ParticipantWhat are you guys doing for setting hostnames?
I want to set a unique hostname in my deployment scripts, any ideas how to do that?
October 25, 2008 at 1:26 am #374550Patrick Fergus
Participanten0’s MAC address is a decent choice. It’s virtually guaranteed (except in the case of manufacturer error) to be unique, although it is hard to have a user read it to you. There’s code to determine the MAC address for en0 in Bombich’s AD binding script.
A less decent but possible choice is the serial number of the machine–this should be available through system_profiler. However, after replacing a computer ‘s logic board the serial number usually becomes inaccessible.
We’re using the user’s shortnames, which is fraught with pain for changing them when machines change hands. However, it’s unbelievably handy for remotely assisting people across the network.
Whatever you pick, you’d have to set it at startup of a freshly built machine. The basic idea is as follows:[code]scutilPath=/usr/sbin/scutil
hostName=somethingUnique$scutilPath –set ComputerName $hostName
$scutilPath –set LocalHostName $hostName[/code]- PatrickOctober 26, 2008 at 8:02 pm #374559trondah
ParticipantThanks for the tip, ended up using the MAC address.
For anyone interested, here’s the command to fetch it in a useable format:
/sbin/ifconfig en0 | awk ‘/ether/ { gsub(“:”, “”); print $2 }’
October 27, 2008 at 3:38 pm #374564knowmad
Participantthanks to this thread, I just figured out a way to make my first run script a little bit better.
when i have it done i will post it (with as many mentions of who created what parts as i can remember).
what I got from here is a way (reliable so far) of naming the machine and putting the mac address into the report it will generate for record keeping.
THANK YOU!
(I am so damn busy that anything I can grab without having to work out is a huge helpOctober 27, 2008 at 4:15 pm #374566alantrewartha
Participantrather than unfriendly MAC addresses, we store unique names (composed of ‘inventory tag’ and principal user) in OD computer records (which are obv keyed to MAC addresses).
part of our NBRestore process curl’s a name from a server that works as a sort of proxy DSCL command (the server being hooked up to OD already, when the NB’d client isn’t) llike this
[code]hwAddress=`/sbin/ifconfig en0 | awk ‘/ether/ { print $2 }’`
myHostName=`curl -s http://10.197.X.Y/dscl.php?MAC=$hwAddress`
[/code]PHP on the server amounts to little more than this…
[code]if ($_GET[‘MAC’])
$output= shell_exec(“dscl -url /LDAPv3/opendirectory -search /Computers dsAttrTypeNative:macAddress “.$_GET[‘MAC’]. “| cut -f1”);
echo $output;
[/code]slightly round the houses – but very simple in practice. not tried adapting it to instaDMG-process scripts. might be simpler if you can hook client up to OD and change hostname.
November 4, 2008 at 12:52 pm #374642Rusty Myers
ParticipantI did something similar for host names (computer names).
I took Bombich’s script to set the name from NetRestore and modified it to run at each boot. I wrote a script that downloads a CSV file from my website so that I can update hostnames. The CSV file is replaced daily on the laptops connected to the internet.
I would have preferred using MCX, but we didn’t have time to set it up. There is probably a better way, but I couldn’t find a way to lock down the host name on the laptops either and I had to keep the host names the same through the year (k-12). I’d still like to know how to lock a share name without MCX or the script.
[code]#!/bin/bash
##Script to test for the availability of internet and download, copy, and overwrite a csv file that has updated computer names.
#Set loop variable.
viperecho=FALSEwhile [ $viperecho = ‘FALSE’ ];do
# If block to test internet availability
if ping -nc 3 http://mywebserver.com | grep ‘100%’ >/dev/null 2>&1 ;
then
echo “failed to connect to server”
else
cd /tmp
mkdir ownhard
pwd
# This is to copy file from webserver to localhost
echo “Downloading computer names file”
curl http://mywebserver.com/managment/computernames/computernames.csv > /tmp/ownhard/computernames.csv
echo “Done downloading”
cp /tmp/ownhard/computernames.csv /Library/Scripts/ETC/sharenames/ownhard.csv
echo “Exiting Loop”
viperecho=TRUE
fi
done[/code]November 4, 2008 at 5:37 pm #374651knowmad
ParticipantThis is a system we used WAY back when I was running the labs at queens college, think os 7/8/9 days. We used a program called RevRdist to keep machines up to date and inline. We ran into a problem of people renaming hard drives and thereby messing with the RevRdist runs.
We made a script that ran at boot, noon and 5pm. It was apple script and it basically looked at a hidden file that was set in place by the last RevRdist run. If the HD was named the same as that file, it did nothing. If the names differed, it changed the HD to match.We also use to run several other scripts in a similar fashion …script checks for presence of an empty hidden file, if not there, run script and create file then quit, if it is there then don’t run.
You might be able to set a cron job that checks the name of the computer once an hour, same with shares…..
course there are ways to make MCX do this with fewer issues…..
more on that when my boss is not walking down the hall. -
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed