Magellan Linux

Contents of /trunk/installer/include/prepare_networking.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1023 - (show annotations) (download) (as text)
Sun May 30 17:39:49 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 1536 byte(s)
-fixed header
-fixed a typo
1 #!/bin/bash
2 # $Id$
3
4 : ${INSTALL_ROOT="/mnt/magellan"}
5
6 add_network_config()
7 {
8 local nic="$1"
9 shift
10
11 echo "$@" >> ${INSTALL_ROOT}/etc/conf.d/net."${nic}"
12 }
13
14 # create empty file
15 :> ${INSTALL_ROOT}/etc/conf.d/net.${NETWORK_NIC}
16
17 case ${NETWORK_METHOD} in
18 static)
19 add_network_config ${NETWORK_NIC} 'ONBOOT="yes"'
20 add_network_config ${NETWORK_NIC} 'NETWORKING="static"'
21 add_network_config ${NETWORK_NIC} "IP=\"${NETWORK_IP}\""
22 add_network_config ${NETWORK_NIC} "NETMASK=\"${NETWORK_NETMASK}\""
23 add_network_config ${NETWORK_NIC} "BROADCAST=\"${NETWORK_BROADCAST}\""
24 add_network_config ${NETWORK_NIC} "GATEWAY=\"${NETWORK_GATEWAY}\""
25 add_network_config ${NETWORK_NIC} "NAMESERVER=\"${NETWORK_NAMESERVER}\""
26 ;;
27 dhcp)
28 add_network_config ${NETWORK_NIC} 'ONBOOT="yes"'
29 add_network_config ${NETWORK_NIC} 'NETWORKING="dhcp"'
30 add_network_config ${NETWORK_NIC} 'DHCP_PROG="/sbin/dhcpcd"'
31 add_network_config ${NETWORK_NIC} 'DHCP_START="-t 10"'
32 add_network_config ${NETWORK_NIC} 'DHCP_STOP="-k"'
33 ;;
34 none)
35 add_network_config ${NETWORK_NIC} 'ONBOOT="no"'
36 ;;
37 esac
38
39 echo "${NETWORK_HOSTNAME}" > ${INSTALL_ROOT}/etc/hostname
40
41 if [[ ${NETWORK_METHOD} = static ]]
42 then
43 # the 'a' in the sed line appends a line after the regex (127.0.0.1.*localhost)
44 sed -i "/127.0.0.1.*localhost/ a \${NETWORK_IP}\t${NETWORK_HOSTNAME}.${NETWORK_DOMAIN}\t${NETWORK_HOSTNAME}" ${INSTALL_ROOT}/etc/hosts
45 else
46 sed -i "s:^\(127.0.0.1.*localhost\):\1\t${NETWORK_HOSTNAME}.${NETWORK_DOMAIN}\t${NETWORK_HOSTNAME}:" ${INSTALL_ROOT}/etc/hosts
47 fi

Properties

Name Value
svn:executable *