]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/init.d/functions.network
- fixed bug on checking is file with interface description exist,
[projects/rc-scripts.git] / rc.d / init.d / functions.network
CommitLineData
b0443108 1#
391798b5 2# $Id: functions.network,v 1.24 1999/09/28 12:48:16 kloczek Exp $
b0443108 3#
7e04fe0e 4# This is not a shell script; it provides functions to network scripts
5# that source it.
6
12d804ca
JK
7get_ldap_config ()
8{
9 [ -x /usr/bin/ldapsearch ] || exit 1
10 # Initialise fields which can have multiple values:
11 IPV6_ADDR=""
12 IPADDR_ALIASES=""
13
14 QUERY="(&(objectclass=pldinterface)(if_device=$1))"
15 if [ -n "$LDAP_BASE_DN" ] ; then
16 BSWITCH='-b"$LDAP_BASE_DN"'
17 else
18 BSWITH=''
19 fi
20 ldapsearch "$BSWITCH" "$QUERY" | grep "=" | sed -e "s/=/ /" | {
21 while read FIELD VALUE ; do
22 # Field, which have name compatible with other
23 # LDAP object
24 if [ "$FIELD" = "iphostnumber" ] ; then
25 VAR="ADDR";
26 else # Other fields
27 VAR=`echo "$FIELD" | grep "^if_" \
28 | tr [:lower:] [:upper:] \
29 | sed -e "s/IF_//"`
30 fi
31 # Fields which can have multiple values:
32 if [ "$VAR" = "IPV6_ADDR" \
33 -o "$VAR" = "IPADDR_ALIASES" ] && \
34 [ -n "`eval echo \$$VAR`" ] ; then
35 echo "$VAR=\"\$$VAR $VALUE\"" ;
36 # single value fields, or the first value
37 elif [ -n "$VAR" ] ; then eval "$VAR=\"$VALUE\"" ;
38 echo "$VAR=\"$VALUE\"" ;
39 fi
40 done
41 }
42}
43
7e04fe0e 44source_config ()
45{
391798b5 46 DEVNAME=`basename $CONFIG | sed 's/^ifcfg-//g'`
7e04fe0e 47
391798b5 48 if [ -f $CONFIG ] ; then
49 . /etc/sysconfig/interfaces/$CONFIG
50 elif [ "$USE_LDAP" = "yes" ] ; then
51 eval `get_ldap_config $DEVNAME`
12d804ca 52 fi
7e04fe0e 53}
54
55do_netreport ()
56{
57 # Notify programs that have requested notification
58 ( cd /var/run/netreport || exit
59 for i in * ; do
60 [ -f $i ] && \
61 kill -SIGIO $i >/dev/null 2>&1 || \
62 rm -f $i >/dev/null 2>&1
63 done
64 )
65}
66
67need_hostname()
68{
69 if [ "`hostname`" = "(none)" -o "`hostname`" = "localhost" -o \
70 "`hostname`" = "localhost.localdomain" ]; then
71 NEEDHOSTNAME=yes
72 else
73 unset NEEDHOSTNAME
74 fi
75}
76
77set_hostname()
78{
79 echo "$1" > /etc/HOSTNAME
80 hostname $1
81 if ! grep search /etc/resolv.conf; then
82 domain=`echo $1 | sed 's/^[^\.]*\.//'`
83 echo "search $domain" >> /etc/resolv.conf
84 fi
85}
86
767c8707 87# PLD/Linux network functions
7e04fe0e 88