Contents of /alx-src/tags/alxconf-0_6_4_5/functions/config_network.sh
Parent Directory | Revision Log
Revision 219 -
(show annotations)
(download)
(as text)
Tue Mar 8 20:42:05 2005 UTC (19 years, 6 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/functions/config_network.sh
File MIME type: application/x-sh
File size: 2882 byte(s)
Tue Mar 8 20:42:05 2005 UTC (19 years, 6 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/functions/config_network.sh
File MIME type: application/x-sh
File size: 2882 byte(s)
new
1 | # configures networkin on the host via mysql db settings |
2 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_network.sh,v 1.2 2005-03-08 20:42:05 niro Exp $ |
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 | # and now put them in usable var names and export them systemwide |
32 | 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 | } |
42 | |
43 | config_networking() |
44 | { |
45 | #first of all get the vars |
46 | get_network_settings |
47 | |
48 | # debug |
49 | echo "0: ${ALX_HOSTNAME}" |
50 | echo "1: ${ALX_MODULE}" |
51 | echo "2: ${ALX_DOMAIN}" |
52 | echo "3: ${ALX_NETWORKING}" |
53 | echo "4: ${ALX_IP}" |
54 | echo "5: ${ALX_NETMASK}" |
55 | echo "6: ${ALX_DNS}" |
56 | echo "7: ${ALX_GATEWAY}" |
57 | echo "8: ${ALX_BROADCAST}" |
58 | |
59 | # hostname && hosts |
60 | echo "${ALX_HOSTNAME}" > /etc/hostname |
61 | echo -e "127.0.0.1\t${ALX_HOSTNAME}.${ALX_DOMAIN}\t${ALX_HOSTNAME}" > /etc/hosts |
62 | |
63 | # network devices |
64 | |
65 | # always on boot |
66 | echo 'ONBOOT="yes"' > /etc/conf.d/net.eth0 |
67 | echo "NETWORKING=\"${ALX_NETWORKING}\"" >> /etc/conf.d/net.eth0 |
68 | |
69 | case ${ALX_NETWORKING} in |
70 | dhcp|DHCP) |
71 | echo 'DHCP_PROG="/sbin/dhcpcd"' >> /etc/conf.d/net.eth0 |
72 | # -k kills the dhcp-cache at system shutdown |
73 | # -z will not |
74 | echo 'DHCP_STOP="-z"' >> /etc/conf.d/net.eth0 |
75 | #timeout after 10 seconds |
76 | echo 'DHCP_START="-t 10"' >> /etc/conf.d/net.eth0 |
77 | ;; |
78 | |
79 | static|STATIC) |
80 | # add hostname with valid ip to hosts |
81 | echo -e "${ALX_IP}\t${ALX_HOSTNAME}.${ALX_DOMAIN}\t${ALX_HOSTNAME}" >> /etc/hosts |
82 | echo "IP=\"${ALX_IP}\"" >> /etc/conf.d/net.eth0 |
83 | echo "NETMASK=\"${ALX_NETMASK}\"" >> /etc/conf.d/net.eth0 |
84 | echo "BROADCAST=\"${ALX_BROADCAST}\"" >> /etc/conf.d/net.eth0 |
85 | ;; |
86 | esac |
87 | |
88 | # gateway or gateway overrides |
89 | if [[ ${ALX_GATEWAY} != NULL ]] |
90 | then |
91 | echo "GATEWAY=\"${ALX_GATEWAY}\"" >> /etc/conf.d/net.eth0 |
92 | echo 'GATEWAY_IF="eth0"' >> /etc/conf.d/net.eth0 |
93 | fi |
94 | |
95 | # nameserver or nameserver overrides |
96 | if [[ ${ALX_DNS} != NULL ]] |
97 | then |
98 | echo "nameserver ${ALX_DNS}" > /etc/resolv.conf |
99 | fi |
100 | |
101 | # unset all vars |
102 | unset ALX_HOSTNAME |
103 | unset ALX_MODULE |
104 | unset ALX_DOMAIN |
105 | unset ALX_NETWORKING |
106 | unset ALX_IP |
107 | unset ALX_NETMASK |
108 | unset ALX_DNS |
109 | unset ALX_GATEWAY |
110 | unset ALX_BROADCAST |
111 | } |