On Fri, 3 Apr 2009 00:01:20 +1000 Jud <jud@judfilm.net> wrote:
On Wed, 1 Apr 2009 20:48:33 +0200 Dieter Plaetinck <dieter@plaetinck.be> wrote:
On Thu, 2 Apr 2009 00:06:46 +1000 Jud <jud@judfilm.net> wrote:
Just to get the ball rolling. This script would be started by the boot process outside of aif. Any ideas/comments welcome.
#!/bin/sh # Proof of Concept bash (same as other mail)
# ToDo: # Work backwards - test for wireless then wired eth2/eth1/wlan1/wlan0/eth0 any others? # Make into function(s)? # More Sanity Tests? # Another layer - groups of mac address for a profile type - profile:desktop01:<mac>,<mac>,<mac> # How would the boot process call this script without interrupting the possibility of a normal install?
# Get the MAC address for eth0 var=$(ifconfig -a | grep eth0)
# We only need the MAC Address var=$(echo ${var: -19}) cool. i never did such a -19 thing. how does this work?
Substring Extraction 9.2 in the Advanced Bash Scripting Guide
The command says keep the 19 characters from the right of the string.
I do have a problem with the string, it contains a space or tab at the end. echo in the above command seems to remove it but without the echo it remains and I need to add another line: var=${var// /}. No problem, but was curious to know if there is a better way.
Try this: var=$(ifconfig -a | awk '/^eth0/ {print $5}')
you can do just var=${var: -19} btw
# Convert to be a filename for our purposes; Strip out ':' var=$(echo ${var//:/})
# Make sure it is Hex aka within the MAC Address specs and ifconfig output if [[ $var =~ [[:xdigit:]] ]]; then echo "$var".profile else echo "error"; exit 1 fi
# Check if file exists and is readable if [ -r "$var.profile" ]; then
# Start Auto Install, when finished reboot # Note: for auto-reboot the install drive should not be the primary boot device aif -p automatic -c $var.profile && reboot
# End of File
Looking good! keep it up. Dieter
ok thanks, more to follow...