My work needs to clone some Thin Clients and they use Ubuntu as base to the VMware Client, but the problem is we have to edit manually the line in the /etc/vmware/view-mandatory-config with the MAC of the Hardware.
view.sslVerificationMode = "3"
view.defaultUser = "CM-d4_85_64_71_58_44"
view.autoConnectDesktop = "TRUE"
view.autoConnectBroker = "TRUE"
view.kioskLogin = "TRUE"
view.nonInteractive = "TRUE"
view.fullScreen = "TRUE"
view.nomenubar = "TRUE"
view.defaultBroker = "viewcs"
We need to create a script that run automatically at boot (1 time and delete it self) and get the MAC of eth0
and past it like in the config file above.
view.defaultUser = "CM-d4_85_64_71_58_44"
We need this so we can save a lot of time.
---EDIT--- With what was answered I did the following script, still incomplete but Is working.
MAC=$(ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}')
echo "
view.sslVerificationMode = *3*
view.autoConnectDesktop = *TRUE*
view.autoConnectBroker = *TRUE*
view.kioskLogin = *TRUE*
view.nonInteractive = *TRUE*
view.fullScreen = *TRUE*
view.nomenubar = *TRUE*
view.defaultBroker = *viewcs*
view.defaultUser = *CM-${MAC//:/_}*
" > /etc/vmware/view-mandatory-config;
sed -i 's/*/"/g' /etc/vmware/view-mandatory-config
Is incomplete because, I don't know how to print (") in the file so I've used * and after I used "sed" to change * to ("), it's working like a charm.
I don't know why but I was not able to make this script run in boot.
First, I set it into /etc/rc.local and it did not ran. Second, I tried to put it in crontab as @reboot /etc/vmware/MAC.sh, and it not worked.
Thanks for your help.
This should give you the string you want.
Replace
eth0
with whatever the interface is. Output:The
grep
code came from here:https://stackoverflow.com/questions/245916/best-way-to-extract-mac-address-from-ifconfig-output