#!/bin/bash
# Change current network profile

profile=$1

if [ -z "$profile" ] ; then
	echo  "usage: `basename $0` <profile>"
	exit 1
fi

files=`find /etc -name "*.$profile" 2>/dev/null`

if [ -z "$files" ] ; then
    echo "unknown profile $profile"
    exit 1
fi

echo "switching network profile to $profile"
for file in $files; do
    (cd `dirname $file` && ln -nsf `basename $file` `basename $file .$2`)
done

# restart network
/etc/init.d/network restart

# change host name
hostname `grep HOSTNAME /etc/sysconfig/network | cut -d= -f2`
