[arch-releng] Get Mac Address for profiles - Proof of Concept

Dieter Plaetinck dieter at plaetinck.be
Wed Apr 1 14:48:33 EDT 2009


On Thu, 2 Apr 2009 00:06:46 +1000
Jud <jud at 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?
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


More information about the arch-releng mailing list