#!/bin/sh
################################################################################
# TmsSetupModuleController Sets up a Tms Module Controller
# T.Barnaby, BEAM Ltd, 2007-03-23
################################################################################
#
#
# This scripts sets up a TMS Module Controller for operation.
#
# Usage: tmsSetupModuleController <number> <ethernet mac address (00:01:02:03:04:05)>
usage(){
echo >&2 "Usage: $0 <number> <ethernet mac address>"
exit 1
}
while getopts "h" oname
do
case "$oname" in
*) usage;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -lt 1 ]; then usage; fi
num=$1
if [ $# == 2 ]; then
macAddress=$2
else
macAddress=""
fi
# Set up root file system for pick up
#rm -fr /usr/tms/rootfs-${num}
mkdir -p /usr/tms/rootfs-${num}
cp -a /usr/tms/rootfs/* /usr/tms/rootfs-${num}
# Modify DHCP entry
if [ "$macAddress" != "" ]; then
sed -e "s/\(host tmsmod${num}.*ethernet \)\(\S*\);/\1${macAddress};/" /etc/dhcp/dhcpd.conf > /tmp/dhcpd.conf
mv /tmp/dhcpd.conf /etc/dhcp/dhcpd.conf
service dhcpd restart
fi
# Install TMS configuration data
sed -e "s/^ModuleControllerNumber:.*$/ModuleControllerNumber:\t\t${num}/" /etc/tmsPuServer.conf > /usr/tms/rootfs-${num}/etc/tmsPuServer.conf
# Sets up hosts
cp hosts /usr/tms/rootfs-${num}/etc/hosts
if ! grep "^boapns" /usr/tms/rootfs-${num}/etc/services > /dev/null 2>&1
then
echo "boapns 12000/tcp # BEAM BOAP Name Server" >> /usr/tms/rootfs-${num}/etc/services
echo "boapns 12000/udp # BEAM BOAP Name Server" >> /usr/tms/rootfs-${num}/etc/services
fi
exit 0