Annotation of /alx-src/trunk/tinyalxconfig-ng/functions/config_network.sh
Parent Directory | Revision Log
Revision 456 -
(hide annotations)
(download)
(as text)
Thu Jun 5 19:10:14 2008 UTC (16 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 3471 byte(s)
Thu Jun 5 19:10:14 2008 UTC (16 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 3471 byte(s)
-typo
1 | niro | 456 | # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/config_network.sh,v 1.10 2008-06-05 19:10:14 niro Exp $ |
2 | niro | 386 | # configures networkin on the host via mysql db settings |
3 | |||
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 | evaluate_table cfg_network | ||
16 | |||
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 | # # update confd-networking default iface | ||
31 | # [ ! -d ${SETTINGSPATH} ] && install -d ${SETTINGSPATH} | ||
32 | # echo "${iface}" > ${SETTINGSPATH}/confd-networking | ||
33 | |||
34 | # configure all available interfaces but activate only the default_iface! | ||
35 | iface_list=$(mysqldo "select iface from cfg_interfaces where serial='${ALX_SERIAL}'") | ||
36 | |||
37 | for iface in ${iface_list} | ||
38 | do | ||
39 | # initialize the config | ||
40 | :> /etc/conf.d/net.${iface} | ||
41 | |||
42 | # retrieve information from mysql | ||
43 | evaluate_table cfg_interfaces "where serial='${ALX_SERIAL}' and iface='${iface}'" | ||
44 | |||
45 | if [[ ${iface} = ${cfg_network_default_iface} ]] | ||
46 | then | ||
47 | add_iface_cfg "ONBOOT=yes" | ||
48 | else | ||
49 | add_iface_cfg "ONBOOT=no" | ||
50 | fi | ||
51 | |||
52 | add_iface_cfg NETWORKING=${cfg_interfaces_networking} | ||
53 | |||
54 | case ${cfg_interfaces_networking} in | ||
55 | dhcp|DHCP) | ||
56 | add_iface_cfg "DHCP_PROG=/sbin/udhcpc" | ||
57 | # timeout after 10 seconds and quit after retrieving a lease | ||
58 | add_iface_cfg 'DHCP_START="-t 10 -q"' | ||
59 | ;; | ||
60 | |||
61 | static|STATIC) | ||
62 | # add hostname with valid ip to hosts | ||
63 | echo -e "${cfg_interfaces_ip}\t${cfg_interfaces_hostname}.${cfg_interfaces_domain}\t${cfg_interfaces_hostname}" >> /etc/hosts | ||
64 | add_iface_cfg "IP=${cfg_interfaces_ip}" | ||
65 | add_iface_cfg "NETMASK=${cfg_interfaces_netmask}" | ||
66 | add_iface_cfg "BROADCAST=${cfg_interfaces_broadcast}" | ||
67 | ;; | ||
68 | esac | ||
69 | |||
70 | # gateway or gateway overrides | ||
71 | if [[ ${cfg_interfaces_gateway} != NULL ]] | ||
72 | then | ||
73 | add_iface_cfg "GATEWAY=${cfg_interfaces_gateway}" | ||
74 | fi | ||
75 | |||
76 | # nameserver or nameserver overrides | ||
77 | if [[ ${cfg_interfaces_dns} != NULL ]] | ||
78 | then | ||
79 | add_iface_cfg "NAMESERVER="${cfg_interfaces_dns}"" | ||
80 | fi | ||
81 | |||
82 | # force mac address override | ||
83 | if [[ ${cfg_interfaces_forcemacto} != NULL ]] | ||
84 | then | ||
85 | add_iface_cfg FORCE_MAC_TO=${cfg_interfaces_forcemacto} | ||
86 | fi | ||
87 | |||
88 | # wireless extensions | ||
89 | local value | ||
90 | local var | ||
91 | for var in cfg_interfaces_wireless_bitrate \ | ||
92 | cfg_interfaces_wireless_channel \ | ||
93 | cfg_interfaces_wireless_essid \ | ||
94 | cfg_interfaces_wireless_frequency \ | ||
95 | cfg_interfaces_wireless_mode \ | ||
96 | cfg_interfaces_wireless_nick \ | ||
97 | cfg_interfaces_wireless_auth_mode \ | ||
98 | cfg_interfaces_wireless_key_length \ | ||
99 | cfg_interfaces_wireless_key \ | ||
100 | cfg_interfaces_wireless_key_ascii | ||
101 | do | ||
102 | # get the value of $var | ||
103 | eval value=\$$(echo ${var}) | ||
104 | |||
105 | # write it only if not empty | ||
106 | if [[ -n ${value} ]] && [[ ${value} != NULL ]] | ||
107 | then | ||
108 | # remove cfg_interfaces_from var and convert to upcase | ||
109 | add_iface_cfg "$(echo ${var/cfg_network_/} | tr '[:lower:]' '[:upper:]')=${value}" | ||
110 | fi | ||
111 | |||
112 | # clear value | ||
113 | unset value | ||
114 | done | ||
115 | |||
116 | # setup wpa-driver (only zydas atm) | ||
117 | case ${cfg_interfaces_module} in | ||
118 | zd1211) add_iface_cfg "WIRELESS_WPA_DRIVER=zydas" ;; | ||
119 | esac | ||
120 | done | ||
121 | } |