/[baselayout]/trunk/net-scripts/net.modules.d/system
Gentoo

Contents of /trunk/net-scripts/net.modules.d/system

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1318 - (show annotations) (download)
Tue Jul 19 21:27:12 2005 UTC (9 years, 2 months ago) by uberlord
File size: 3559 byte(s)
Fixes dns_search_path variable
1 #!/bin/bash
2 # Copyright (c) 2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 # void system_depend(void)
6 #
7 # Sets up the dependancies for the module
8 system_depend() {
9 after interface essidnet
10 before dhcp
11 }
12
13 # bool system_check_installed(void)
14 #
15 # Always returns 0 as we are writing to files
16 system_check_installed() {
17 return 0
18 }
19
20 # char* system_provides(void)
21 #
22 # Returns a string to change module definition for starting up
23 system_provides() {
24 echo "system"
25 }
26
27 # bool system_check_depends(void)
28 #
29 # Checks to see if we have the needed functions
30 system_check_depends() {
31 return 0
32 }
33
34 # char* ifconfig_get_vars(char *interface)
35 #
36 # Returns a string spaced with possible user set configuration variables
37 system_get_vars() {
38 echo "dns_servers_$1 dns_domain_$1 dns_search_path_$1 ntp_servers_$1 nis_domain_$1 nis_servers_$1"
39 }
40
41 system_dns() {
42 local iface="$1" ifvar=$( bash_variable "$1" ) x
43 local conffile="${statedir}/${iface}/resolv.conf" tmpfile="${conffile}.$$"
44
45 # Nameserver setup for the essid if required
46 local -a servers
47 eval servers=( \"\$\{dns_servers_${ifvar}\[@\]\}\" )
48 [[ -z ${servers} ]] && return 0
49
50 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}"
51 chmod 644 "${tmpfile}"
52
53 eval x=\"\$\{dns_domain_${ifvar}\}\"
54 [[ -n ${x} ]] && echo "domain ${x}" >> "${tmpfile}"
55
56 for x in ${servers[@]}; do
57 echo "nameserver ${x}" >> "${tmpfile}"
58 done
59
60 eval x=\"\$\{dns_search_path_${ifvar}\}\"
61 [[ -n ${x} ]] && echo "search ${x}" >> "${tmpfile}"
62
63 mv "${tmpfile}" "${conffile}"
64 }
65
66 system_ntp() {
67 local iface="$1" ifvar=$( bash_variable "$1" ) x
68 local conffile="${statedir}/${iface}/ntp.conf" tmpfile="${conffile}.$$"
69 local -a servers
70
71 eval servers=( \"\$\{ntp_servers_${ifvar}\[\@\]\}\" )
72 [[ -z ${servers} ]] && return 0
73
74 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}"
75 chmod 644 "${tmpfile}"
76
77 echo "restrict default noquery notrust nomodify" >> "${tmpfile}"
78 echo "restrict 127.0.0.1" >> "${tmpfile}"
79
80 for x in ${servers[@]}; do
81 echo "restrict ${x} nomodify notrap noquery" >> "${tmpfile}"
82 echo "server ${x}" >> "${tmpfile}"
83 done
84
85 echo "driftfile /var/lib/ntp/ntp.drift" >> "${tmpfile}"
86 echo "logfile /var/log/ntp.log" >> "${tmpfile}"
87
88 mv "${tmpfile}" "${conffile}"
89 }
90
91 system_nis() {
92 local iface="$1" ifvar=$( bash_variable "$1" ) domain x
93 local conffile="${statedir}/${iface}/yp.conf" tmpfile="${conffile}.$$"
94 local -a servers
95
96 eval servers=( \"\$\{nis_servers_${ifvar}\[\@\]\}\" )
97 eval domain=\"\$\{nis_domain_${ifvar}\}\"
98 [[ -z ${servers} && -z ${domain} ]] && return 0
99
100 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}"
101 chmod 644 "${tmpfile}"
102
103 if [[ -n ${domain} ]]; then
104 /bin/hostname -y "${domain}"
105 if [[ -n ${servers} ]]; then
106 for x in ${servers}; do
107 echo "domain ${domain} server ${x}" >> "${tmpfile}"
108 done
109 else
110 echo "domain ${domain} broadcast" >> "${tmpfile}"
111 fi
112 else
113 for x in ${servers}; do
114 echo "ypserver ${x}" >> "${tmpfile}"
115 done
116 fi
117
118 [[ -f ${conffile} && ! -f "${conffile}.sv" ]] \
119 && mv "${conffile}" "${conffile}.sv"
120 mv "${tmpfile}" "${conffile}"
121 }
122
123 # bool system_post_start(char *iface)
124 #
125 # Configures the host system for dns, ntp and nis information
126 # Always returns 0
127 system_post_start() {
128 local iface="$1"
129
130 system_dns "${iface}"
131 system_ntp "${iface}"
132 system_nis "${iface}"
133
134 return 0
135 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20