install gawk by default (required for gcc49 build)
[unleashed-kayak.git] / net_help.sh
blob3c4e978e33075132bcdff982c8a736721169cb96
1 #!/usr/bin/bash
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
24 # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25 # Use is subject to license terms.
28 Ether(){
29 /sbin/ifconfig -a | \
30 /usr/bin/awk '/UP/{if($2 !~ /LOOPBACK/){iface=$1;}} /ether/{if(iface){print $2; exit;}}' | \
31 /bin/tr '[:lower:]' '[:upper:]' | \
32 /bin/sed -e 's/^/ 0/g;s/:/ 0/g; s/0\([0-9A-F][0-9A-F]\)/\1/g; s/ //g;'
35 UseDNS() {
36 server=$1; shift
37 domain=$1
38 EnableDNS $domain $*
39 SetDNS $server
42 EnableDNS() {
43 domain=$1
44 if [ ! -z $domain ]; then
45 cat <<EOF > $ALTROOT/etc/resolv.conf
46 domain $domain
47 search $*
48 EOF
50 sed -I -e 's/^hosts:.*/hosts: files dns/;' $ALTROOT/etc/nsswitch.conf
51 sed -I -e 's/^ipnodes:.*/ipnodes: files dns/;' $ALTROOT/etc/nsswitch.conf
54 SetDNS() {
55 # NOTE: If the nsswitch.conf file specifies DNS in a manner other than:
56 # "files dns", setting EnableDNS will have to become more sophisticated.
57 /usr/bin/grep -c 'files dns' $ALTROOT/etc/nsswitch.conf 2> /dev/null > /dev/null || EnableDNS
59 for srv in $*; do
60 echo nameserver $srv >> $ALTROOT/etc/resolv.conf
61 done