blob: 5de43cdc1b4d5ff24ed026d28058736880863d42 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
depend() {
need hostname
before bootmisc
}
checkconfig_nis() {
if [[ -f /etc/nisdomainname ]] ; then
ewarn $"You should stop using /etc/nisdomainname and use /etc/conf.d/domainname"
export NISDOMAIN=$(</etc/nisdomainname)
return 0
fi
[[ -n ${NISDOMAIN} ]]
}
checkconfig_dns() {
if [[ -f /etc/dnsdomainname ]] ; then
ewarn $"You should stop using /etc/dnsdomainname and use /etc/conf.d/domainname"
export DNSDOMAIN=$(</etc/dnsdomainname)
fi
[[ -z ${DNSDOMAIN} ]] && return 1
if ! touch /etc/resolv.conf 2> /dev/null ; then
ewarn $"Unable to set domain in resolv.conf (ro root?)"
return 1
else
return 0
fi
}
start() {
# Ensure that we have a hostname binary or function
source /lib/rcscripts/net.modules.d/helpers.d/functions
local retval=0
local retval2=0
if checkconfig_nis ; then
ebegin $"Setting NIS domainname to" ${NISDOMAIN}
hostname -y "${NISDOMAIN}"
retval=$?
eend ${retval} $"Failed to set the NIS domainname"
fi
if checkconfig_dns ; then
ebegin $"Setting DNS domainname to" ${DNSDOMAIN}
resolv=$(grep -v '^[[:space:]]*domain' /etc/resolv.conf)
[[ ${OVERRIDE} == "1" ]] \
&& resolv="${resolv}"$'\n'"domain ${DNSDOMAIN}" \
|| resolv="domain ${DNSDOMAIN}"$'\n'"${resolv}"
echo "${resolv}" > /etc/resolv.conf
retval2=$?
eend ${retval2} $"Failed to set the DNS domainname"
fi
return $((retval + retval2))
}
# vim:ts=4
|