Netsetup: Difference between revisions
Jump to navigation
Jump to search
(New page: The netsetup script completes the schoolserver network configuration. ==Netsetup== #!/bin/bash #usage: ./netsetup school 192.168.5.44 192.168.5.1 255.255.255.0 #where school is the name of...) |
No edit summary |
||
(5 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 |
||
#usage: ./netsetup school 192.168.5.44 192.168.5.1 255.255.255.0 |
#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 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 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) |
#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) |
#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 |
#where the fourth parameter is optional (default: 255.255.255.0). Enter it if it is different |
||
set -x |
set -x |
||
set -o nounset |
set -o nounset |
||
set -o errexit |
set -o errexit |
||
echo "install.sh version 2.0" > /tmp/summary.log |
echo "install.sh version 2.0" > /tmp/summary.log |
||
#complete install and configuration of XS |
#complete install and configuration of XS |
||
#get command line arguments school, server |
#get command line arguments school, server |
||
USAGE="usage: ./XSinstall school server" |
USAGE="usage: ./XSinstall school server" |
||
set +o errexit |
set +o errexit |
||
if [ -z $1 ]; then echo $USAGE; exit 1;fi |
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 ] |
||
then SCHOOL=$1 |
then SCHOOL=$1 |
||
else echo $USAGE; exit 1 |
else echo $USAGE; exit 1 |
||
fi |
fi |
||
if [ -n $2 ] |
if [ -n $2 ] |
||
then SERVER=$2 |
then SERVER=$2 |
||
else echo $USAGE; exit 1 |
else echo $USAGE; exit 1 |
||
fi |
fi |
||
#this needs to be fixed so that default is $SERVER substituting '1' for the last field |
#this needs to be fixed so that default is $SERVER substituting '1' for the last field |
||
if [ -n $3 ] |
if [ -n $3 ] |
||
then NAMESERVER=$3 |
then NAMESERVER=$3 |
||
else NAMESERVER= "192.168.5.1" |
else NAMESERVER= "192.168.5.1" |
||
fi |
fi |
||
if [ -n $4 ] |
if [ -n $4 ] |
||
then NETMASK=$4 |
then NETMASK=$4 |
||
else NETMASK= "255.255.255.0" |
else NETMASK= "255.255.255.0" |
||
fi |
|||
set -o errexit |
set -o errexit |
||
echo "school is $SCHOOL" >> /tmp/summary.log |
|||
echo " |
echo "school is $SCHOOL" >> /tmp/summary.log |
||
echo " |
echo "server is $SERVER" >> /tmp/summary.log |
||
echo "WAN |
echo "WAN nameserver is $NAMESERVER" >> /tmp/summary.log |
||
echo " |
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 |
|||
echo "Edit /etc/hosts" >> /tmp/summary.log |
|||
⚫ | |||
LINE1=" $SERVER schoolserver1.$SCHOOL.schoolnet.gov.np" |
LINE1=" $SERVER schoolserver1.$SCHOOL.schoolnet.gov.np" |
||
sed "s/conference.schoolserver/conference.schoolserver\n$LINE1\n/g" /etc/hosts > /tmp/hosts |
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: |
#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 |
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 |
|||
⚫ | |||
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