lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # $Id: config-dns.sh, v10.08.05, 2010-08-05 15:00:00 |
| 4 | # |
| 5 | # usage: config-dns.sh [<dns1>] [<dns2>] |
| 6 | # |
| 7 | path_sh=`nv get path_sh` |
| 8 | . $path_sh/global.sh |
| 9 | echo "Info: config-dns.sh $1 $2 start" >> $test_log |
| 10 | fname=$path_conf"/etc/resolv.conf" |
| 11 | fbak=$path_conf"/etc/resolv_conf.bak" |
| 12 | |
| 13 | # in case no previous file |
| 14 | touch $fname |
| 15 | |
| 16 | # backup file without nameserver part |
| 17 | sed -e '/nameserver/d' $fname > $fbak |
| 18 | |
| 19 | # set primary and seconday DNS |
| 20 | if [ "x$1" != "x" ]; then |
| 21 | echo "nameserver $1" > $fname |
| 22 | else # empty dns |
| 23 | rm -f $fname |
| 24 | fi |
| 25 | if [ "x$2" != "x" ]; then |
| 26 | echo "nameserver $2" >> $fname |
| 27 | fi |
| 28 | |
| 29 | cat $fbak >> $fname |
| 30 | rm -f $fbak |
| 31 | |