Annotation of /alx-src/branches/alxconf-060/functions/config_network.sh
Parent Directory | Revision Log
Revision 276 -
(hide annotations)
(download)
(as text)
Wed Aug 3 17:56:00 2005 UTC (19 years, 1 month ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/functions/config_network.sh
File MIME type: application/x-sh
File size: 3400 byte(s)
Wed Aug 3 17:56:00 2005 UTC (19 years, 1 month ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/functions/config_network.sh
File MIME type: application/x-sh
File size: 3400 byte(s)
added mac fake support
1 | niro | 276 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_network.sh,v 1.8 2005-08-03 17:56:00 niro Exp $ |
2 | niro | 218 | # configures networkin on the host via mysql db settings |
3 | |||
4 | get_network_settings() | ||
5 | { | ||
6 | local x i all DB_NETWORK | ||
7 | |||
8 | #all arrays: | ||
9 | # -> hostname modules domain networking ip netmask dns gateway broadcast | ||
10 | |||
11 | all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
12 | "select hostname, | ||
13 | module, | ||
14 | domain, | ||
15 | networking, | ||
16 | ip, | ||
17 | netmask, | ||
18 | dns, | ||
19 | gateway, | ||
20 | broadcast | ||
21 | from cfg_network where serial='${ALX_SERIAL}'") | ||
22 | |||
23 | #split'em up and put 'em in an array | ||
24 | declare -i i=0 | ||
25 | for x in ${all} | ||
26 | do | ||
27 | DB_NETWORK[${i}]="${x}" | ||
28 | ((i++)) | ||
29 | done | ||
30 | |||
31 | niro | 276 | # and now put in usable var names and export them systemwide |
32 | niro | 218 | export ALX_HOSTNAME="${DB_NETWORK[0]:=NULL}" |
33 | export ALX_MODULE="${DB_NETWORK[1]:=NULL}" | ||
34 | export ALX_DOMAIN="${DB_NETWORK[2]:=NULL}" | ||
35 | export ALX_NETWORKING="${DB_NETWORK[3]:=NULL}" | ||
36 | export ALX_IP="${DB_NETWORK[4]:=NULL}" | ||
37 | export ALX_NETMASK="${DB_NETWORK[5]:=NULL}" | ||
38 | export ALX_DNS="${DB_NETWORK[6]:=NULL}" | ||
39 | export ALX_GATEWAY="${DB_NETWORK[7]:=NULL}" | ||
40 | export ALX_BROADCAST="${DB_NETWORK[8]:=NULL}" | ||
41 | niro | 276 | |
42 | # the new mac address hack | ||
43 | export ALX_FORCEMACTO=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
44 | "select forcemacto from cfg_network where serial='${ALX_SERIAL}'") | ||
45 | niro | 218 | } |
46 | |||
47 | config_networking() | ||
48 | { | ||
49 | #first of all get the vars | ||
50 | get_network_settings | ||
51 | |||
52 | # debug | ||
53 | niro | 241 | # echo "0: ${ALX_HOSTNAME}" |
54 | # echo "1: ${ALX_MODULE}" | ||
55 | # echo "2: ${ALX_DOMAIN}" | ||
56 | # echo "3: ${ALX_NETWORKING}" | ||
57 | # echo "4: ${ALX_IP}" | ||
58 | # echo "5: ${ALX_NETMASK}" | ||
59 | # echo "6: ${ALX_DNS}" | ||
60 | # echo "7: ${ALX_GATEWAY}" | ||
61 | # echo "8: ${ALX_BROADCAST}" | ||
62 | niro | 218 | |
63 | # hostname && hosts | ||
64 | echo "${ALX_HOSTNAME}" > /etc/hostname | ||
65 | niro | 255 | echo -e "127.0.0.1\tlocalhost.${ALX_DOMAIN}\tlocalhost\t${ALX_HOSTNAME}" > /etc/hosts |
66 | niro | 218 | |
67 | # network devices | ||
68 | |||
69 | # always on boot | ||
70 | echo 'ONBOOT="yes"' > /etc/conf.d/net.eth0 | ||
71 | echo "NETWORKING=\"${ALX_NETWORKING}\"" >> /etc/conf.d/net.eth0 | ||
72 | |||
73 | case ${ALX_NETWORKING} in | ||
74 | dhcp|DHCP) | ||
75 | echo 'DHCP_PROG="/sbin/dhcpcd"' >> /etc/conf.d/net.eth0 | ||
76 | # -k kills the dhcp-cache at system shutdown | ||
77 | # -z will not | ||
78 | echo 'DHCP_STOP="-z"' >> /etc/conf.d/net.eth0 | ||
79 | #timeout after 10 seconds | ||
80 | echo 'DHCP_START="-t 10"' >> /etc/conf.d/net.eth0 | ||
81 | ;; | ||
82 | |||
83 | static|STATIC) | ||
84 | # add hostname with valid ip to hosts | ||
85 | echo -e "${ALX_IP}\t${ALX_HOSTNAME}.${ALX_DOMAIN}\t${ALX_HOSTNAME}" >> /etc/hosts | ||
86 | echo "IP=\"${ALX_IP}\"" >> /etc/conf.d/net.eth0 | ||
87 | echo "NETMASK=\"${ALX_NETMASK}\"" >> /etc/conf.d/net.eth0 | ||
88 | echo "BROADCAST=\"${ALX_BROADCAST}\"" >> /etc/conf.d/net.eth0 | ||
89 | ;; | ||
90 | esac | ||
91 | |||
92 | # gateway or gateway overrides | ||
93 | if [[ ${ALX_GATEWAY} != NULL ]] | ||
94 | then | ||
95 | echo "GATEWAY=\"${ALX_GATEWAY}\"" >> /etc/conf.d/net.eth0 | ||
96 | echo 'GATEWAY_IF="eth0"' >> /etc/conf.d/net.eth0 | ||
97 | fi | ||
98 | |||
99 | niro | 276 | # force mac address override |
100 | if [[ ${ALX_FORCEMACTO} != NULL ]] | ||
101 | then | ||
102 | echo "FORCE_MAC_TO=\"${ALX_FORCEMACTO}\"" >> /etc/conf.d/net.eth0 | ||
103 | fi | ||
104 | |||
105 | niro | 218 | # nameserver or nameserver overrides |
106 | if [[ ${ALX_DNS} != NULL ]] | ||
107 | then | ||
108 | echo "nameserver ${ALX_DNS}" > /etc/resolv.conf | ||
109 | fi | ||
110 | |||
111 | niro | 266 | # setup smb.conf (little sed magic:) |
112 | cat ${ALX_SKELETONS}/samba/smb.conf > /etc/samba/smb.conf | ||
113 | sed -i -e "s:\(workgroup = \).*:\1${ALX_DOMAIN}:" /etc/samba/smb.conf | ||
114 | |||
115 | niro | 218 | # unset all vars |
116 | unset ALX_HOSTNAME | ||
117 | unset ALX_MODULE | ||
118 | unset ALX_DOMAIN | ||
119 | unset ALX_NETWORKING | ||
120 | unset ALX_IP | ||
121 | unset ALX_NETMASK | ||
122 | unset ALX_DNS | ||
123 | unset ALX_GATEWAY | ||
124 | unset ALX_BROADCAST | ||
125 | } | ||
126 | niro | 255 |