1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#! /bin/bash
#
# Written by Andrew McMillan, 10th November 1999
# - styled on the pcmcia 'network' script by David Hinds (thanks)
#
DEVICE=whereami
RESOLV=/etc/resolv.conf
function buildresolv() {
for PART in $@ ; do
case "$PART" in
domain|search|nameserver)
echo -en "\n$PART"
;;
*)
echo -en " $PART"
;;
esac
done
echo ""
}
if [ -x '/sbin/resolvconf' ] ; then
# Just use resolvconf
buildresolv $@ | resolvconf -a $DEVICE 2>&1 | logger -t whereami-setresolver
else
# Insert a section into the file in a manner similar to
# the entries inserted by the pcmcia package
if [ "$1" != "" ] ; then
echo -n "# $DEVICE begin" > $RESOLV.N
buildresolv $@ >> $RESOLV.N
echo -e "\n# $DEVICE end" >> $RESOLV.N
# Now replace that section into the existing file
sed -e "/# $DEVICE begin/,/# $DEVICE end/d" $RESOLV >> $RESOLV.N
mv $RESOLV.N $RESOLV
fi
fi
|