RSS Git Download  Clone
Raw Blame History
#!/bin/sh
################################################################################
#	TmsSetup	Sets up a Tms System Controller
#			T.Barnaby,	BEAM Ltd,	2007-02-22
################################################################################
#
#
# This scripts sets up a TMS System Controller for operation after a bare metal
# install.

# fileReplace <filename> <searchParameter> <replaceParamter>
fileReplace()
{
	if grep "$2" $1 > /dev/null 2>&1
	then
		res=`sed -e "s'$2'$3'" $1`
		echo "$res" > $1
	else
		echo "$3" >> $1
	fi
}

fileReplaceIfNotSet()
{
	if ! grep "$3" $1 > /dev/null 2>&1
	then
		res=`sed -e "s'$2'$3'" $1`
		echo "$res" > $1
	fi
}

install=0
if [ "$1" == "-install" ]; then
	install=1
fi

# Basic setup
./tmsInit

# Disable SELINUX
if ! grep "SELINUX=disabled" /etc/sysconfig/selinux > /dev/null 2>&1; then
	fileReplace /etc/sysconfig/selinux "SELINUX=.*" "SELINUX=disabled"
fi

# Enable syslog from remote systems
#sed -e "s/^SYSLOGD_OPTIONS=.*$/SYSLOGD_OPTIONS=\"-r -m 0\"/" /etc/sysconfig/syslog > /tmp/syslog
#mv /tmp/syslog /etc/sysconfig/syslog
#if [ $install != "1" ]; then
#	service syslog restart
#fi

# Setup freedesktop menu item
cp tms.menu /etc/xdg/menus/applications-merged/tms.menu


# Setup Network
#if [ ! -e /etc/sysconfig/network-scripts/ifcfg-eth1 ]; then
#	cp ifcfg-eth1 /etc/sysconfig/network-scripts
#	if [ $install != "1" ]; then
#		ifdown eth1; ifup eth1
#	fi
#fi

# Sets up DNS
#cp resolv.conf /etc/resolv.conf
#cp tmsnet.rev tmsnet.zone /var/named
#cp named /etc/sysconfig/named
#cp named.conf /etc/named.conf
#chkconfig named on
#service named restart

# Sets up DHCP
if ! grep "BEAM" /etc/dhcp/dhcpd.conf > /dev/null 2>&1; then
	cp dhcpd.conf /etc/dhcp/dhcpd.conf
fi
systemctl enable dhcpd
if [ $install != "1" ]; then
	systemctl restart dhcpd
fi

# Sets up TFTP for boot
systemctl enable tftp
if [ $install != "1" ]; then
	systemctl restart tftp
fi

# Sets up NTP time server
if ! grep "TMS" /etc/ntp.conf > /dev/null 2>&1
then
	echo "" >> /etc/ntp.conf
	echo "# TMS time server" >> /etc/ntp.conf
	echo "restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap" >> /etc/ntp.conf
fi
systemctl enable ntpd
if [ $install != "1" ]; then
	systemctl restart ntpd
fi

mkdir -p /data

# Sets up nfs
if ! grep "^/usr/tms " /etc/exports > /dev/null 2>&1
then
	echo "/usr/tms *.tmsnet(async,ro)" >> /etc/exports
fi
if ! grep "^/usr/tms/rootfs " /etc/exports > /dev/null 2>&1
then
	echo "/usr/tms/rootfs *.tmsnet(async,rw,no_root_squash)" >> /etc/exports
fi
if ! grep "^/usr/tms/rootfs-1 " /etc/exports > /dev/null 2>&1
then
	echo "/usr/tms/rootfs-1 *.tmsnet(async,rw,no_root_squash)" >> /etc/exports
fi
if ! grep "^/usr/tms/rootfs-2 " /etc/exports > /dev/null 2>&1
then
	echo "/usr/tms/rootfs-2 *.tmsnet(async,rw,no_root_squash)" >> /etc/exports
fi
if ! grep "^/usr/tms/rootfs-3 " /etc/exports > /dev/null 2>&1
then
	echo "/usr/tms/rootfs-3 *.tmsnet(async,rw,no_root_squash)" >> /etc/exports
fi
if ! grep "^/usr/tms/rootfs-4 " /etc/exports > /dev/null 2>&1
then
	echo "/usr/tms/rootfs-4 *.tmsnet(async,rw,no_root_squash)" >> /etc/exports
fi
if ! grep "^/data " /etc/exports > /dev/null 2>&1
then
	echo "/data *.tmsnet(async,rw,no_root_squash)" >> /etc/exports
fi

systemctl enable nfs-server
if [ $install != "1" ]; then
	systemctl start nfs-server
fi

# Enable and Disable some services
systemctl enable ntpd
systemctl disable bluetooth
systemctl disable firewalld
systemctl disable ModemManager

# Misc
#systemctl disable NetworkManager
#systemctl enable network
#systemctl enable time-stream
#systemctl disable ypbind

systemctl enable boapns-tms
if [ $install != "1" ]; then
	systemctl restart boapns-tms
fi

# Setup TmsServer
systemctl enable tmsServer@1
if [ $install != "1" ]; then
	systemctl restart tmsServer@1
fi
systemctl enable tmsWeb
if [ $install != "1" ]; then
	systemctl restart tmsWeb
fi

# Setup yum
#for f in `ls /etc/yum.repos.d`; do
#	if [ $f != "tms.repo" ]; then
#		sed -e "s/^enabled=.*$/enabled=0/" /etc/yum.repos.d/$f > /tmp/$f
#		mv /tmp/$f /etc/yum.repos.d/$f
#	fi
#done

# Setup for GUI boot
echo 'DESKTOP="KDE"' > /etc/sysconfig/desktop
echo 'DISPLAYMANAGER="KDE"' >> /etc/sysconfig/desktop

# Add standard user
if ! grep -q "^tms:" /etc/passwd; then
	useradd -p '$1$KJHkHb.f$CCPRPaaEi3ozOCvsBkUoP/' tms
fi

# Setup file system sharing
#if ! grep "^#BEAM" /etc/samba/smb.conf > /dev/null 2>&1; then
#	sed -e "s/workgroup.*=.*$/workgroup = TMS/" /etc/samba/smb.conf > /tmp/smb.conf
#	cp /tmp/smb.conf /etc/samba/smb.conf
#	cat "smb.conf" >> /etc/samba/smb.conf
#	
#	#smbpasswd -a tms
#fi

exit 0