#!/bin/sh
# rc
# script called at system startup/reboot

# if [ `hostname` = "de-etrax001" -o `hostname` = "de-etrax004" -o `hostname` = "de-etrax005" -o `hostname` = "de-etrax006" -o `hostname` = "de-etrax007" ]; 
# then
# 
#   while [ ! -e "/home/hadaq/apr07/TRB_FPGA_jam.sh2" ]
#   do
#     sleep 1
#   done
# 
# 
#   if [ -e "/home/hadaq/apr07/hosts" ]
#   then
#     cp /home/hadaq/apr07/hosts /etc/hosts
#   fi
#   if [ -e "/home/hadaq/apr07/syslog.conf" ]
#   then
#     cp /home/hadaq/apr07/syslog.conf /etc/syslog.conf
#     /etc/init.d/sysklogd stop
#     /etc/init.d/sysklogd start 
#   fi
# 
#   /usr/bin/logger -p local0.error "TRB: Init hardware started"
#   /home/hadaq/apr07/TRB_FPGA_jam.sh
#   /usr/bin/logger -p local0.error "Init hardware done"
# 
# fi

# ---------------------------
# set the time server
if [ ! -e "/etc/localtime" ]
then
  ln -s /home/hadaq/Berlin /etc/localtime
fi
/home/hadaq/ntpdate 140.181.90.22

# ---------------------------
# reset MAC address to have the same last to digits of the hostname
# - checks in script $resetMACsScript 
#   for matching hostnames and reconfigures eth0
# P.Zumbruch, GSI, 13-01-2010 

resetMACsScript=/home/hadaq/EPICS/startupProcedures/resetMACs.sh
[ -x "$resetMACsScript" ] && $resetMACsScript -e eth0 || echo "$resetMACsScript" failed
unset resetMACsScript

# ---------------------------
# start EPICS IOC script 
# - checks in script $startEpicsIocScript
#   for matching hostnames and starts IOC in background
# P.Zumbruch, GSI, 11-02-2010

startEpicsIocScript=/home/hadaq/EPICS/startupProcedures/startEpicsIoc.sh
startEpicsIocListFile=/home/hadaq/EPICS/startupProcedures/iocListFile-Etrax.txt
startEpicsIocCommand="$startEpicsIocScript -f $startEpicsIocListFile"
[ -x "$startEpicsIocScript" ] && [ -f "$startEpicsIocListFile" ] && $startEpicsIocCommand || echo "$startEpicsIocScript" failed
unset startEpicsIocScript startEpicsIocListFile

# ---------------------------
export PATH=$PATH:/home/hadaq:/home/hadaq/bin
