#!/bin/sh

cd ~/online

shutDown
sleep 20

if [ -x cfg/ahcal/testForMappingChange.sh ]; then
    cfg/ahcal/testForMappingChange.sh >> cfg/ahcal/testForMapping.log &
fi

if [ -r sktHstGeneric.lock ]; then

 echo "File sktHstGeneric.lock exists; cannot start sktHstGeneric"

else

 timestamp=`date +%s`
 nohup sktHstGeneric $@ 1> data/log/Log$timestamp.out_${HOST}Hst 2> data/log/Log$timestamp.err_${HOST}Hst &
 echo "Log file used: data/log/Log$timestamp.out_${HOST}Hst"

 rm ActiveLog.out_Hst
 rm ActiveLog.err_Hst
 ln -s data/log/Log$timestamp.out_${HOST}Hst ActiveLog.out_Hst
 ln -s data/log/Log$timestamp.err_${HOST}Hst ActiveLog.err_Hst
fi

sleep 1

if [ -r runner.lock ]; then

 echo "File runner.lock exists; cannot start runner"

else

 timestamp=`date +%s`
 nohup runner $@ 1> data/log/Log$timestamp.out_$HOST 2> data/log/Log$timestamp.err_$HOST &
 echo "Log file used: data/log/Log$timestamp.out_$HOST"

 rm ActiveLog.out
 rm ActiveLog.err
 ln -s data/log/Log$timestamp.out_${HOST} ActiveLog.out
 ln -s data/log/Log$timestamp.err_${HOST} ActiveLog.err
fi
