aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
blob: e5175e019484a2a30996637c250e220a78982562 (plain)
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
43
44
45
46
47
48
49
50
# This is not a shell script; it provides functions to network scripts
# that source it.

source_config ()
{
    DEVNAME=`basename $CONFIG | sed 's/^ifcfg-//g'`

    if basename $CONFIG | grep -q '[^g]-' ; then
	PARENTCONFIG=`echo $CONFIG | sed 's/-[^-]*$//g'`
	PARENTDEVNAME=`basename $PARENTCONFIG | sed 's/^ifcfg-//g'`
	[ -f $PARENTCONFIG ] || {
	    echo "Missing config file $PARENTCONFIG." >&2
	    exit 1
	}
	. $PARENTCONFIG
    fi
    . $CONFIG
}

do_netreport ()
{
  # Notify programs that have requested notification
  ( cd /var/run/netreport || exit
    for i in * ; do
      [ -f $i ] && \
        kill -SIGIO $i >/dev/null 2>&1 || \
          rm -f $i >/dev/null 2>&1
    done
  )
}

need_hostname()
{
    if [ "`hostname`" = "(none)" -o "`hostname`" = "localhost" -o \
	 "`hostname`" = "localhost.localdomain" ]; then
	NEEDHOSTNAME=yes
    else
	unset NEEDHOSTNAME
    fi
}

set_hostname()
{
    echo "$1" > /etc/HOSTNAME
    hostname $1
    if ! grep search /etc/resolv.conf; then
	domain=`echo $1 | sed 's/^[^\.]*\.//'`
	echo "search $domain" >> /etc/resolv.conf
    fi
}