#!/bin/sh

HOST=`hostname`
PREFIX=`echo ${HOST} | cut -c 1-4`
NNO=`echo ${HOST} | cut -c 5-6`

if [ "${PREFIX}" != "node" ]; then
	echo "$0: expected hostname 'nodeXX', got ${HOST}."
	exit 1
fi

if [ "${NNO}" -lt 15 -o "${NNO}" -gt 20 ]; then
	echo "$0: expected node number [15;20], got ${NNO}."
	exit 1
fi

ETH="eth1"
TUN="tun0"
BRD="br0"

route delete default
route delete -net 192.168.0.0/16
if [ -f /etc/saved.conf.resolv ]; then
    cat /etc/saved.conf.resolv > /etc/resolv.conf
else
    echo "search hpc.mgsu.ru" > /etc/resolv.conf
    echo "nameserver 10.10.0.254" >> /etc/resolv.conf
fi
ifconfig ${TUN} down
ifconfig ${BRD} down
ifconfig ${ETH} down
ip tunnel del ${TUN}
brctl delbr br0
