Netsetup: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
The netsetup script completes the schoolserver network configuration.
The netsetup script completes the schoolserver network configuration. The command is:
./netsetup school server nameserver netmask
where school is the name of the school (one word), server is the IP address of the server, e.g. 192.168.5.45 or DHCP if the IP adress is supplied by the ISP, nameserver is the IP address of the network nameserver (e.g. 192.168.5.1), and netmask is the network mask (e.g. 255, 255,255.0).
==Netsetup==
==Netsetup==
#!/bin/bash
#!/bin/bash
Line 16: Line 18:
USAGE="usage: ./XSinstall school server"
USAGE="usage: ./XSinstall school server"
set +o errexit
set +o errexit
if [ -z $1 ]; then echo $USAGE; exit 1;fichange wiki page name
if [ -z $1 ]; then echo $USAGE; exit 1;fi
if [ -z $2 ]; then echo $USAGE; exit 1;fi
if [ -z $2 ]; then echo $USAGE; exit 1;fi
if [ -n $1 ]
if [ -n $1 ]
Line 38: Line 40:
echo "school is $SCHOOL" >> /tmp/summary.log
echo "school is $SCHOOL" >> /tmp/summary.log
echo "server is $SERVER" >> /tmp/summary.log
echo "server is $SERVER" >> /tmp/summary.log
echo "WAN nameserver is $NAMESERVER >> /tmp/summary.log
echo "WAN nameserver is $NAMESERVER" >> /tmp/summary.log
echo "WAN net mask is $NETMASK >> /tmp/summary.log
echo "WAN net mask is $NETMASK" >> /tmp/summary.log
echo "execute olpc domain_config script" >> /tmp/summary.log
echo "execute olpc domain_config script" >> /tmp/summary.log
/etc/sysconfig/olpc-scripts/domain_config $SCHOOL.schoolnet.gov.np
/etc/sysconfig/olpc-scripts/domain_config $SCHOOL.schoolnet.gov.np
Line 56: Line 58:
cp /tmp/work /etc/resolv.conf
cp /tmp/work /etc/resolv.conf
service network restart
service network restart

sed "s/BROADCAST.*$/BROADCAST=172.18.1.255\nGATEWAY=$SERVER/g" /tmp/eth1 /tmp/work
sed "s/BROADCAST.*$/BROADCAST=172.18.1.255\nGATEWAY=$SERVER/g" /tmp/eth1 /tmp/work
cp /tmp/work /tmp/eth1
cp /tmp/work /tmp/eth1

Latest revision as of 05:18, 21 November 2008

The netsetup script completes the schoolserver network configuration. The command is:

./netsetup school server nameserver netmask 

where school is the name of the school (one word), server is the IP address of the server, e.g. 192.168.5.45 or DHCP if the IP adress is supplied by the ISP, nameserver is the IP address of the network nameserver (e.g. 192.168.5.1), and netmask is the network mask (e.g. 255, 255,255.0).

Netsetup

#!/bin/bash
#usage: ./netsetup school 192.168.5.44 192.168.5.1 255.255.255.0
#where school is the name of the school, e.g. Kavre (use one, preferably short word for the schoolname)
#where the second parameter is the IP address of the server: 192.168.5.44
#where the third parameter is optional when the nameserver is the server IP address with the last field = 1 (i.e. 192.168.5.1)
#otherwise, enter the nameserver IP address (e.g. 192.168.5.xxx)
#where the fourth parameter is optional (default: 255.255.255.0). Enter it if it is different
set -x
set -o nounset
set -o errexit
echo "install.sh version 2.0" > /tmp/summary.log
#complete install and configuration of XS
#get command line arguments school, server
USAGE="usage: ./XSinstall school server"
set +o errexit
if [ -z $1 ]; then echo $USAGE; exit 1;fi
if [ -z $2 ]; then echo $USAGE; exit 1;fi
if [ -n $1 ]
  then SCHOOL=$1
  else echo $USAGE; exit 1 
fi
if [ -n $2 ]
  then SERVER=$2
  else echo $USAGE; exit 1
fi
#this needs to be fixed so that default is $SERVER substituting '1' for the last field
if [ -n $3 ]
  then NAMESERVER=$3
  else NAMESERVER= "192.168.5.1"
fi
if [ -n $4 ]
  then NETMASK=$4
  else NETMASK= "255.255.255.0"
fi
set -o errexit
echo "school is $SCHOOL" >> /tmp/summary.log
echo "server is $SERVER" >> /tmp/summary.log
echo "WAN nameserver is $NAMESERVER" >> /tmp/summary.log
echo "WAN net mask is $NETMASK" >> /tmp/summary.log
echo "execute olpc domain_config script" >> /tmp/summary.log
/etc/sysconfig/olpc-scripts/domain_config $SCHOOL.schoolnet.gov.np
echo "Edit /etc/hosts"  >> /tmp/summary.log
#edit /etc/hosts
LINE1=" $SERVER   schoolserver1.$SCHOOL.schoolnet.gov.np"
sed "s/conference.schoolserver/conference.schoolserver\n$LINE1\n/g" /etc/hosts > /tmp/hosts
cp /tmp/hosts /etc/hosts
#confirm that /etc/sysconfig/network contains the lines:
sed "s/IPV6_AUTOCONF.*$/IPV6_AUTOCONF=no\nHOSTNAME=schoolserver1.$SCHOOL.schoolnet.gov.np/g" /tmp/network > /tmp/work
cp /tmp/work /etc/sysconfig/network
echo "/etc/sysconfig/network" >> /tmp/summary.log
cat /etc/sysconfig/network >> /tmp/summary.log
echo "fix resolv.conf" >> /tmp/summary.log
sed "s/nameserver.*$/nameserver 172.18.0.1\nnameserver $SERVER/g" /etc/resolv.conf > /tmp/work
cp /tmp/work /etc/resolv.conf
service network restart
sed "s/BROADCAST.*$/BROADCAST=172.18.1.255\nGATEWAY=$SERVER/g" /tmp/eth1 /tmp/work
cp /tmp/work /tmp/eth1