summaryrefslogtreecommitdiff
path: root/scripts/add_bootfile_eth_hwid
diff options
context:
space:
mode:
authorTom Grennan <tgrennan@io.vyatta.com>2007-12-14 13:08:55 -0800
committerTom Grennan <tgrennan@io.vyatta.com>2007-12-14 13:08:55 -0800
commit5705741d4b523d0869d694ed320a333d3b87937d (patch)
tree053ada8342f6c8f0c5d4bdc335dea499328989bb /scripts/add_bootfile_eth_hwid
parent6ea2c7979320d032c2213d271309d6026d57775b (diff)
downloadvyatta-cfg-quagga-5705741d4b523d0869d694ed320a333d3b87937d.tar.gz
vyatta-cfg-quagga-5705741d4b523d0869d694ed320a333d3b87937d.zip
fix modification of config file interface sub-block
Diffstat (limited to 'scripts/add_bootfile_eth_hwid')
-rwxr-xr-xscripts/add_bootfile_eth_hwid30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/add_bootfile_eth_hwid b/scripts/add_bootfile_eth_hwid
new file mode 100755
index 00000000..2a9cc69c
--- /dev/null
+++ b/scripts/add_bootfile_eth_hwid
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# add ethnet interface sub-block to configure file
+
+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 {$/,/^}$/ {
+ /^}$/i\
+ ethernet '"$eth"' {\
+ hw-id: '"$hwid"'\
+ link-detect\
+ }
+ }' $bootfile