Hi all;
What I am trying to do is a script that does the following:
1. reads what mac model it is (MacBookPro10,1) and use MacBookPro as an identifier... (or MacPro8,1) and use MacPro.
Then based on that name the computer if its a laptop ML-COMPUTERSERIAL or desktop/imac MW-COMPUTERSERIAL
I am pretty sure the code before the If/then Else is ok, its the IF/then that I am having trouble with so if someone could look at it and show me how to do it or clean that part up I would appreciate it...
So far I have the following:
If you can't read the whole code you can read it here better:
http://slexy.org/view/s2166IItwi
What I am trying to do is a script that does the following:
1. reads what mac model it is (MacBookPro10,1) and use MacBookPro as an identifier... (or MacPro8,1) and use MacPro.
Then based on that name the computer if its a laptop ML-COMPUTERSERIAL or desktop/imac MW-COMPUTERSERIAL
I am pretty sure the code before the If/then Else is ok, its the IF/then that I am having trouble with so if someone could look at it and show me how to do it or clean that part up I would appreciate it...
So far I have the following:
Code:
#!/bin/bash
laptop="ML-"
workstation="MW-”
tld="yourdomain.com"
serial=`ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }'`
model=`ioreg -l | awk '/product-name/ { split($0, line, "\""); printf("%s\n", line[4]); }'
if ["$model”=="$MacBookPro*” ]; then :laptop
:laptop
/usr/sbin/scutil --set ComputerName $laptop$serial
/usr/sbin/scutil --set LocalHostName $laptop$serial
/usr/sbin/scutil --set HostName "${laptop}${serial}.${tld}"
else
["$model”==”$MacPro*” ]; then
:workstation
/usr/sbin/scutil --set ComputerName $workstation$serial
/usr/sbin/scutil --set LocalHostName $workstation$serial
/usr/sbin/scutil --set HostName "${workstation}${serial}.${tld}"
If you can't read the whole code you can read it here better:
http://slexy.org/view/s2166IItwi
Last edited: