Annotation of /alx-src/trunk/tinyalxconfig-ng/functions/config_network.sh
Parent Directory | Revision Log
Revision 539 -
(hide annotations)
(download)
(as text)
Mon Jan 26 17:19:06 2009 UTC (15 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 3213 byte(s)
Mon Jan 26 17:19:06 2009 UTC (15 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 3213 byte(s)
-fixed spelling
1 | niro | 537 | # $Id$ |
2 | niro | 539 | # configures networking on the host via mysql db settings |
3 | niro | 386 | |
4 | niro | 454 | # needs exported iface variable! |
5 | add_iface_cfg() | ||
6 | { | ||
7 | echo "$@" >> /etc/conf.d/net.${iface} | ||
8 | } | ||
9 | |||
10 | config_networking() | ||
11 | { | ||
12 | local iface | ||
13 | |||
14 | # retrieve informations about hostname and co | ||
15 | niro | 473 | evaluate_table_xml cfg_network |
16 | niro | 454 | |
17 | # configure hostname and domain settings: | ||
18 | niro | 456 | echo "${cfg_network_hostname}" > /etc/hostname |
19 | niro | 454 | echo -e "127.0.0.1\tlocalhost.${cfg_network_domain}\tlocalhost\t${cfg_network_hostname}" > /etc/hosts |
20 | |||
21 | # if ! check_network_settings | ||
22 | # then | ||
23 | # echo -e "${COLYELLOW}Could not retrieve network settings, doing nothing ...${COLDEFAULT}" | ||
24 | # return 1 | ||
25 | # fi | ||
26 | |||
27 | # remove all old nics and modules configs | ||
28 | find /etc/conf.d -type f -name 'net.*' | xargs rm | ||
29 | |||
30 | # configure all available interfaces but activate only the default_iface! | ||
31 | iface_list=$(mysqldo "select iface from cfg_interfaces where serial='${ALX_SERIAL}'") | ||
32 | |||
33 | for iface in ${iface_list} | ||
34 | do | ||
35 | # initialize the config | ||
36 | :> /etc/conf.d/net.${iface} | ||
37 | |||
38 | # retrieve information from mysql | ||
39 | niro | 473 | evaluate_table_xml cfg_interfaces "where serial='${ALX_SERIAL}' and iface='${iface}'" |
40 | niro | 454 | |
41 | if [[ ${iface} = ${cfg_network_default_iface} ]] | ||
42 | then | ||
43 | add_iface_cfg "ONBOOT=yes" | ||
44 | else | ||
45 | add_iface_cfg "ONBOOT=no" | ||
46 | fi | ||
47 | |||
48 | add_iface_cfg NETWORKING=${cfg_interfaces_networking} | ||
49 | |||
50 | case ${cfg_interfaces_networking} in | ||
51 | dhcp|DHCP) | ||
52 | add_iface_cfg "DHCP_PROG=/sbin/udhcpc" | ||
53 | # timeout after 10 seconds and quit after retrieving a lease | ||
54 | add_iface_cfg 'DHCP_START="-t 10 -q"' | ||
55 | ;; | ||
56 | |||
57 | static|STATIC) | ||
58 | # add hostname with valid ip to hosts | ||
59 | echo -e "${cfg_interfaces_ip}\t${cfg_interfaces_hostname}.${cfg_interfaces_domain}\t${cfg_interfaces_hostname}" >> /etc/hosts | ||
60 | add_iface_cfg "IP=${cfg_interfaces_ip}" | ||
61 | add_iface_cfg "NETMASK=${cfg_interfaces_netmask}" | ||
62 | add_iface_cfg "BROADCAST=${cfg_interfaces_broadcast}" | ||
63 | ;; | ||
64 | esac | ||
65 | |||
66 | # gateway or gateway overrides | ||
67 | if [[ ${cfg_interfaces_gateway} != NULL ]] | ||
68 | then | ||
69 | add_iface_cfg "GATEWAY=${cfg_interfaces_gateway}" | ||
70 | fi | ||
71 | |||
72 | # nameserver or nameserver overrides | ||
73 | if [[ ${cfg_interfaces_dns} != NULL ]] | ||
74 | then | ||
75 | add_iface_cfg "NAMESERVER="${cfg_interfaces_dns}"" | ||
76 | fi | ||
77 | |||
78 | # force mac address override | ||
79 | if [[ ${cfg_interfaces_forcemacto} != NULL ]] | ||
80 | then | ||
81 | add_iface_cfg FORCE_MAC_TO=${cfg_interfaces_forcemacto} | ||
82 | fi | ||
83 | |||
84 | # wireless extensions | ||
85 | local value | ||
86 | local var | ||
87 | for var in cfg_interfaces_wireless_bitrate \ | ||
88 | cfg_interfaces_wireless_channel \ | ||
89 | cfg_interfaces_wireless_essid \ | ||
90 | cfg_interfaces_wireless_frequency \ | ||
91 | cfg_interfaces_wireless_mode \ | ||
92 | cfg_interfaces_wireless_nick \ | ||
93 | cfg_interfaces_wireless_auth_mode \ | ||
94 | cfg_interfaces_wireless_key_length \ | ||
95 | cfg_interfaces_wireless_key \ | ||
96 | cfg_interfaces_wireless_key_ascii | ||
97 | do | ||
98 | # get the value of $var | ||
99 | eval value=\$$(echo ${var}) | ||
100 | |||
101 | # write it only if not empty | ||
102 | if [[ -n ${value} ]] && [[ ${value} != NULL ]] | ||
103 | then | ||
104 | # remove cfg_interfaces_from var and convert to upcase | ||
105 | add_iface_cfg "$(echo ${var/cfg_network_/} | tr '[:lower:]' '[:upper:]')=${value}" | ||
106 | fi | ||
107 | |||
108 | # clear value | ||
109 | unset value | ||
110 | done | ||
111 | |||
112 | # setup wpa-driver (only zydas atm) | ||
113 | case ${cfg_interfaces_module} in | ||
114 | zd1211) add_iface_cfg "WIRELESS_WPA_DRIVER=zydas" ;; | ||
115 | esac | ||
116 | done | ||
117 | } |