Contents of /alx-src/tags/alxconf-0_6_4_5/functions/config_network.sh
Parent Directory | Revision Log
Revision 2145 -
(show annotations)
(download)
(as text)
Tue May 17 11:44:27 2011 UTC (13 years, 4 months ago) by niro
Original Path: alx-src/branches/alxconf-060/functions/config_network.sh
File MIME type: application/x-sh
File size: 3206 byte(s)
Tue May 17 11:44:27 2011 UTC (13 years, 4 months ago) by niro
Original Path: alx-src/branches/alxconf-060/functions/config_network.sh
File MIME type: application/x-sh
File size: 3206 byte(s)
-get database data via evaluate_table() function and use the advantages of xml (no problems with empty values anymore)
1 | # $Id$ |
2 | # configures networking on the host via mysql db settings |
3 | |
4 | config_networking() |
5 | { |
6 | local iface |
7 | local CONFIG |
8 | |
9 | # first of all get the vars |
10 | evaluate_table cfg_network |
11 | |
12 | # get the right nic |
13 | if [[ -z ${cfg_network_iface} ]] || [[ ${cfg_network_iface} = NULL ]] |
14 | then |
15 | # default is 'eth0' |
16 | iface="eth0" |
17 | else |
18 | iface="${cfg_network_iface}" |
19 | fi |
20 | |
21 | # remove all old nics and modules configs |
22 | find /etc/conf.d -type f -name 'net.*' | xargs rm |
23 | find /etc/modprobe.d -type f -name 'net.*' | xargs rm |
24 | |
25 | # update the preliminary network |
26 | # set an device alias for modprobe.conf |
27 | [ ! -d /etc/modprobe.d ] && install -d /etc/modprobe.d |
28 | # update only if not the same (to speed up bootprocess - no depmod) |
29 | if [ ! -f /etc/modprobe.d/net.${iface}.conf ] || |
30 | [[ ${iface} != $(cat /etc/modprobe.d/net.${iface}.conf | cut -d' ' -f2) ]] |
31 | then |
32 | CONFIG=/etc/modprobe.d/net.${iface}.conf |
33 | clearconfig |
34 | addconfig "alias ${iface} ${cfg_network_module}" |
35 | fi |
36 | |
37 | # update confd-networking default iface |
38 | [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} |
39 | CONFIG=${SETTINGSPATH}/confd-networking |
40 | clearconfig |
41 | addconfig "${iface}" |
42 | |
43 | # hostname && hosts |
44 | CONFIG=/etc/hostname |
45 | clearconfig |
46 | addconfig "${cfg_network_hostname}" |
47 | CONFIG=/etc/hosts |
48 | clearconfig |
49 | addconfig -e "127.0.0.1\tlocalhost.${cfg_network_domain}\tlocalhost\t${cfg_network_hostname}" |
50 | case ${cfg_network_networking} in |
51 | static|STATIC) |
52 | # add hostname with valid ip to hosts |
53 | addconfig -e "${ALX_IP}\t${cfg_network_hostname}.${cfg_network_domain}\t${cfg_network_hostname}" |
54 | ;; |
55 | esac |
56 | |
57 | # network devices |
58 | |
59 | # always on boot |
60 | CONFIG=/etc/conf.d/net.${iface} |
61 | clearconfig |
62 | |
63 | addconfig 'ONBOOT="yes"' |
64 | addconfig "NETWORKING=\"${cfg_network_networking}\"" |
65 | case ${cfg_network_networking} in |
66 | dhcp|DHCP) |
67 | addconfig 'DHCP_PROG="/sbin/udhcpc"' |
68 | addconfig 'DHCP_STOP=""' |
69 | #timeout after 10 seconds |
70 | addconfig 'DHCP_START="-t 10"' |
71 | ;; |
72 | |
73 | static|STATIC) |
74 | addconfig "IP=\"${cfg_network_ip}\"" |
75 | addconfig "NETMASK=\"${cfg_network_netmask}\"" |
76 | addconfig "BROADCAST=\"${cfg_network_broadcast}\"" |
77 | ;; |
78 | esac |
79 | |
80 | # force mac address override |
81 | if [[ ${cfg_network_forcemacto} != NULL ]] |
82 | then |
83 | addconfig "FORCE_MAC_TO=\"${cfg_network_forcemacto}\"" |
84 | fi |
85 | |
86 | # wireless extensions |
87 | local value |
88 | local var |
89 | for var in bitrate \ |
90 | channel \ |
91 | essid \ |
92 | frequency \ |
93 | mode \ |
94 | nick \ |
95 | auth_mode \ |
96 | key_length \ |
97 | key \ |
98 | key_ascii |
99 | do |
100 | # get the value of $var |
101 | eval value="\${cfg_network_wireless_$(echo ${var})}" |
102 | |
103 | # write it only if not empty |
104 | if [[ -n ${value} ]] && [[ ${value} != NULL ]] |
105 | then |
106 | # add WIRELESS and use uppercases |
107 | addconfig "WIRELESS_$(echo ${var} | tr [[:lower:] [[:upper:]])=\"${value}\"" |
108 | fi |
109 | |
110 | # clear value |
111 | unset value |
112 | done |
113 | |
114 | # FIXME !!! |
115 | # setup wpa-driver (only zydas atm) |
116 | if [[ ${cfg_network_module} = zd1211 ]] |
117 | then |
118 | addconfig "WIRELESS_WPA_DRIVER=zydas" |
119 | fi |
120 | |
121 | CONFIG=/etc/conf.d/net.routes |
122 | clearconfig |
123 | # gateway or gateway overrides |
124 | if [[ ${cfg_network_gateway} != NULL ]] |
125 | then |
126 | addconfig "default gw ${cfg_network_gateway}" |
127 | fi |
128 | |
129 | CONFIG=/etc/resolv.conf |
130 | clearconfig |
131 | # nameserver or nameserver overrides |
132 | if [[ ${cfg_network_dns} != NULL ]] |
133 | then |
134 | addconfig "nameserver ${cfg_network_dns}" |
135 | fi |
136 | } |