/[vps]/baselayout-vserver/trunk/lib/rcscripts/net.modules.d/system
Gentoo

Contents of /baselayout-vserver/trunk/lib/rcscripts/net.modules.d/system

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Sat Sep 3 16:10:27 2005 UTC (9 years, 1 month ago) by hollow
File size: 3279 byte(s)
import initial baselayout sources (1.12.0_pre8)
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 local -a servers
45
46 eval servers=( \"\$\{dns_servers_${ifvar}\[@\]\}\" )
47 [[ -z ${servers} ]] && return 0
48
49 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}"
50 chmod 644 "${tmpfile}"
51
52 eval x=\"\$\{dns_domain_${ifvar}\}\"
53 [[ -n ${x} ]] && echo "domain ${x}" >> "${tmpfile}"
54
55 for x in ${servers[@]}; do
56 echo "nameserver ${x}" >> "${tmpfile}"
57 done
58
59 eval x=\"\$\{dns_search_path_${ifvar}\}\"
60 [[ -n ${x} ]] && echo "search ${x}" >> "${tmpfile}"
61
62 mv "${tmpfile}" "${conffile}"
63 }
64
65 system_ntp() {
66 local iface="$1" ifvar=$( bash_variable "$1" ) x
67 local conffile="${statedir}/${iface}/ntp.conf" tmpfile="${conffile}.$$"
68 local -a servers
69
70 eval servers=( \"\$\{ntp_servers_${ifvar}\[\@\]\}\" )
71 [[ -z ${servers} ]] && return 0
72
73 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}"
74 chmod 644 "${tmpfile}"
75
76 echo "restrict default noquery notrust nomodify" >> "${tmpfile}"
77 echo "restrict 127.0.0.1" >> "${tmpfile}"
78
79 for x in ${servers[@]}; do
80 echo "restrict ${x} nomodify notrap noquery" >> "${tmpfile}"
81 echo "server ${x}" >> "${tmpfile}"
82 done
83
84 echo "driftfile /var/lib/ntp/ntp.drift" >> "${tmpfile}"
85 echo "logfile /var/log/ntp.log" >> "${tmpfile}"
86
87 mv "${tmpfile}" "${conffile}"
88 }
89
90 system_nis() {
91 local iface="$1" ifvar=$( bash_variable "$1" ) domain x
92 local conffile="${statedir}/${iface}/yp.conf" tmpfile="${conffile}.$$"
93 local -a servers
94
95 eval servers=( \"\$\{nis_servers_${ifvar}\[\@\]\}\" )
96 eval domain=\"\$\{nis_domain_${ifvar}\}\"
97 [[ -z ${servers} && -z ${domain} ]] && return 0
98
99 echo "# Generated by net-scripts for interface ${iface}" > "${tmpfile}"
100 chmod 644 "${tmpfile}"
101
102 if [[ -n ${domain} ]]; then
103 /bin/hostname -y "${domain}"
104 if [[ -n ${servers} ]]; then
105 for x in ${servers}; do
106 echo "domain ${domain} server ${x}" >> "${tmpfile}"
107 done
108 else
109 echo "domain ${domain} broadcast" >> "${tmpfile}"
110 fi
111 else
112 for x in ${servers}; do
113 echo "ypserver ${x}" >> "${tmpfile}"
114 done
115 fi
116
117 mv "${tmpfile}" "${conffile}"
118 }
119
120 # bool system_post_start(char *iface)
121 #
122 # Configures the host system for dns, ntp and nis information
123 # Always returns 0
124 system_post_start() {
125 local iface="$1"
126
127 system_dns "${iface}"
128 system_ntp "${iface}"
129 system_nis "${iface}"
130
131 return 0
132 }
133
134 # vim:ts=4

  ViewVC Help
Powered by ViewVC 1.1.20