/[baselayout]/trunk/net/system.sh
Gentoo

Contents of /trunk/net/system.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download) (as text)
Thu Apr 5 11:18:42 2007 UTC (11 years, 2 months ago) by uberlord
File MIME type: text/x-sh
File size: 2544 byte(s)
    Rewrite the core parts in C. We now provide librc so other programs can
    query runlevels, services and state without using bash. We also provide
    libeinfo so other programs can easily use our informational functions.

    As such, we have dropped the requirement of using bash as the init script
    shell. We now use /bin/sh and have strived to make the scripts as portable
    as possible. Shells that work are bash and dash. busybox works provided
    you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you
    should disable find too.
    zsh and ksh do not work at this time.

    Networking support is currently being re-vamped also as it was heavily bash
    array based. As such, a new config format is available like so
    config_eth0="1.2.3.4/24 5.6.7.8/16"
    or like so
    config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'"

    We will still support the old bash array format provided that /bin/sh IS
    a link it bash.

    ChangeLog for baselayout-1 can be found in our SVN repo.
1 # Copyright 2005-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 _config_vars="$_config_vars dns_servers dns_domain dns_search"
5 _config_vars="$_config_vars ntp_servers nis_servers nis_domain"
6
7 system_depend() {
8 after interface
9 before dhcp
10 }
11
12 _system_dns() {
13 local servers= domain= search= x=
14
15 eval servers=\$dns_servers_${IFVAR}
16 [ -z "${servers}" ] && servers=${dns_servers}
17
18 eval domain=\$dns_domain_${IFVAR}
19 [ -z "${domain}" ] && domain=${dns_domain}
20
21 eval search=\$dns_search_${IFVAR}
22 [ -z "${search}" ] && search=${dns_search}
23
24 [ -z "${servers}" -a -z "${domain}" -a -z "${search}" ] && return 0
25
26 local buffer="# Generated by net-scripts for interface ${IFACE}\n"
27 [ -n "${domain}" ] && buffer="${buffer}domain ${domain}\n"
28 [ -n "${search}" ] && buffer="${buffer}search ${search}\n"
29
30 for x in ${servers} ; do
31 buffer="${buffer}nameserver ${x}\n"
32 done
33
34 # Support resolvconf if we have it.
35 if [ -x /sbin/resolvconf ] ; then
36 printf "${buffer}" | resolvconf -a "${IFACE}"
37 else
38 printf "${buffer}" > /etc/resolv.conf
39 chmod 644 /etc/resolv.conf
40 fi
41 }
42
43 _system_ntp() {
44 local servers= buffer= x=
45
46 eval servers=\$ntp_servers_${IFVAR}
47 [ -z ${servers} ] && servers=${ntp_servers}
48 [ -z ${servers} ] && return 0
49
50 buffer="# Generated by net-scripts for interface ${IFACE}\n"
51 buffer="${buffer}restrict default noquery notrust nomodify\n"
52 buffer="${buffer}restrict 127.0.0.1\n"
53
54 for x in ${servers} ; do
55 buffer="${buffer}restrict ${x} nomodify notrap noquery\n"
56 buffer="${buffer}server ${x}\n"
57 done
58
59 buffer="${buffer}driftfile /var/lib/ntp/ntp.drift\n"
60 buffer="${buffer}logfile /var/log/ntp.log\n"
61
62 printf "${buffer}" > /etc/ntp.conf
63 chmod 644 /etc/ntp.conf
64 }
65
66 _system_nis() {
67 local servers= domain= x= buffer=
68
69 eval servers=\$nis_servers_${IFVAR}
70 [ -z "${servers}" ] && servers=${nis_servers}
71
72 eval domain=\$nis_domain_${IFVAR}
73 [ -z "${domain}" ] && domain=${nis_domain}
74
75 [ -z "${servers}" -a -z "${domain}" ] && return 0
76
77 buffer="# Generated by net-scripts for interface ${iface}\n"
78
79 if [ -n "${domain}" ] ; then
80 hostname -y "${domain}"
81 if [ -n "${servers}" ] ; then
82 for x in ${servers} ; do
83 buffer="${buffer}domain ${domain} server ${x}\n"
84 done
85 else
86 buffer="${buffer}domain ${domain} broadcast\n"
87 fi
88 else
89 for x in ${servers} ; do
90 buffer="${buffer}ypserver ${x}\n"
91 done
92 fi
93
94 printf "${buffer}" > /etc/yp.conf
95 chmod 644 /etc/yp.conf
96 }
97
98 system_pre_start() {
99 _system_dns
100 _system_ntp
101 _system_nis
102
103 return 0
104 }
105
106 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20