This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
lsts_glued/packages/filesystem/fs/etc/rc.d/trex

111 lines
2.5 KiB
Plaintext
Raw Normal View History

2013-07-26 11:23:09 +01:00
TREX_HOME='/opt/lsts/trex'
EUROPA_HOME=/usr/share/europa
TREX_LIBS=$TREX_HOME/lib:/usr/lib
TREX_BINS=$TREX_HOME/bin
TREX_SHARED=$TREX_HOME/share/trex
TREX_NICE=10
TREX_CFG=xtreme2
maybe_upgrade()
{
if ! [ -f $TREX_HOME/trex-*.tar.bz2 ]; then
2013-08-01 16:00:05 +01:00
return 1
2013-07-26 11:23:09 +01:00
fi
echo -n "* Starting T-REX upgrade... "
rm -rf $TREX_HOME/.trex-upgrade &&
mkdir $TREX_HOME/.trex-upgrade &&
tar -x -C $TREX_HOME/.trex-upgrade -f $TREX_HOME/trex-*.tar.bz2 &&
rm $TREX_HOME/trex-*.tar.bz2 &&
for dir in $TREX_HOME/.trex-upgrade/trex-*/*; do
d="$(basename "$dir")"
rm -rf "$TREX_HOME/$d"
mv "$dir" $TREX_HOME
done
rm -rf $TREX_HOME/.trex-upgrade
echo "done"
}
start()
{
maybe_upgrade
if [ -d "${EUROPA_HOME}" ]; then
export EUROPA_HOME
TREX_LIBS=${TREX_LIBS}:$EUROPA_HOME/lib
fi
platform='unknown'
lib_path_var=LD_LIBRARY_PATH
unamestr=`uname`
if [ "$unamestr" = 'Darwin' ]; then
if [ -n "${DYLD_FALLBACK_LIBRARY_PATH+x}" ]; then
export DYLD_FALLBACK_LIBRARY_PATH=${DYLD_FALLBACK_LIBRARY_PATH}:${TREX_LIBS}
else
export DYLD_FALLBACK_LIBRARY_PATH=${TREX_LIBS}
fi
export DYLD_BIND_AT_LAUNCH=YES
else
if [ -n "${LD_LIBRARY_PATH+x}" ]; then
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${TREX_LIBS}
else
export LD_LIBRARY_PATH=${TREX_LIBS}
fi
fi
if [ -n "${PATH+x}" ]; then
export PATH=${PATH}:${TREX_BINS}
else
export PATH=${TREX_BINS}
fi
if [ -n "${TREX_PATH+x}" ]; then
export TREX_PATH=${TREX_PATH}:${TREX_SHARED}/cfg:${TREX_SHARED}/plugins
else
export TREX_PATH=${TREX_SHARED}/cfg:${TREX_SHARED}/plugins
fi
if [ -z "${TREX_LOG_DIR+x}" ]; then
export TREX_LOG_DIR=${TREX_SHARED}/log
fi
py_libs=${TREX_SHARED}/python
if [ -n "${PYTHONPATH+x}" ]; then
export PYTHONPATH=${py_libs}:${PYTHONPATH}
else
export PYTHONPATH=${py_libs}
fi
amc $TREX_CFG --nice=$TREX_NICE < /dev/null > /dev/null 2>&1 &
2013-08-01 16:00:05 +01:00
PID=$!
sleep 1
track_amc $PID > $TREX_LOG_DIR/latest/track_amc.csv &
2013-07-26 11:23:09 +01:00
}
stop()
{
while [ 1 ]; do
echo "* Stopping process..."
killall amc > /dev/null 2>&1
2013-08-01 16:00:05 +01:00
killall -9 track_amc > /dev/null 2>&1
2013-07-26 11:23:09 +01:00
for r in 0 1 2 3 4 5 6 7 8 9; do
if [ -n "$(pidof amc)" ]; then
echo "* Waiting for process to exit ($r)..."
sleep 1
else
echo "* Process not running."
return 1
fi
done
echo "* Forcing exit..."
killall -9 amc > /dev/null 2>&1
sleep 1
done
}