From 5705741d4b523d0869d694ed320a333d3b87937d Mon Sep 17 00:00:00 2001 From: Tom Grennan Date: Fri, 14 Dec 2007 13:08:55 -0800 Subject: fix modification of config file interface sub-block --- scripts/mod_bootfile_eth_hwid | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 scripts/mod_bootfile_eth_hwid (limited to 'scripts/mod_bootfile_eth_hwid') diff --git a/scripts/mod_bootfile_eth_hwid b/scripts/mod_bootfile_eth_hwid new file mode 100755 index 00000000..b913d121 --- /dev/null +++ b/scripts/mod_bootfile_eth_hwid @@ -0,0 +1,37 @@ +#!/bin/bash + +# modify interface sub-block + +shopt -s extglob + +if [[ "$*" == *--help* ]] ; then + echo ${0##*/} [test_]FILE INTERFACE HWID + exit 0 +fi + +if [[ "$1" == test_* ]] ; then + origfile=$1 + bootfile=/tmp/${1##*/}_$$ + cp $origfile $bootfile + trap "diff -c $origfile $bootfile; rm -f $bootfile; exit 0" $? +else + origfile= + bootfile=$1 +fi +eth=$2 +hwid=$3 + +sed -i '/^interfaces {$/,/^}$/ { + /^ ethernet '"$eth"' {$/ { + :join + /\n }$/ { + /hw-id: / s/\(hw-id:\) [0-9a-fA-F:]\+/\1 '"$hwid"'/ + /hw-id: /! s/}$/ hw-id: '"$hwid"'\n }/ + /link-detect/! s/}$/ link-detect\n }/ + b + } + N + b join + } +}' $bootfile + -- cgit v1.2.3