Contents of /alx-src/tags/alxconf-0_6_4_5/functions/config_network.sh
Parent Directory | Revision Log
Revision 290 -
(show annotations)
(download)
(as text)
Thu Aug 18 02:50:47 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: 3531 byte(s)
Thu Aug 18 02:50:47 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: 3531 byte(s)
fixed samba conf issues; now checking for smb2 and 3
1 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_network.sh,v 1.9 2005-08-18 02:50:47 niro Exp $ |
2 | # 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 | # and now put 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 | # 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 | } |
46 | |
47 | config_networking() |
48 | { |
49 | #first of all get the vars |
50 | get_network_settings |
51 | |
52 | # debug |
53 | # 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 | |
63 | # hostname && hosts |
64 | echo "${ALX_HOSTNAME}" > /etc/hostname |
65 | echo -e "127.0.0.1\tlocalhost.${ALX_DOMAIN}\tlocalhost\t${ALX_HOSTNAME}" > /etc/hosts |
66 | |
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 | # 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 | # nameserver or nameserver overrides |
106 | if [[ ${ALX_DNS} != NULL ]] |
107 | then |
108 | echo "nameserver ${ALX_DNS}" > /etc/resolv.conf |
109 | fi |
110 | |
111 | # setup smb.conf (little sed magic:) |
112 | # first get smb version ! |
113 | local smbconf |
114 | [[ $(smbd --version | cut -d' ' -f2) > 2 ]] && smbconf=smb3.conf || smbconf=smb.conf |
115 | |
116 | cat ${ALX_SKELETONS}/samba/${smbconf} > /etc/samba/smb.conf |
117 | sed -i -e "s:\(workgroup = \).*:\1${ALX_DOMAIN}:" /etc/samba/smb.conf |
118 | |
119 | # unset all vars |
120 | unset ALX_HOSTNAME |
121 | unset ALX_MODULE |
122 | unset ALX_DOMAIN |
123 | unset ALX_NETWORKING |
124 | unset ALX_IP |
125 | unset ALX_NETMASK |
126 | unset ALX_DNS |
127 | unset ALX_GATEWAY |
128 | unset ALX_BROADCAST |
129 | } |
130 |