Added T-REX service script.
This commit is contained in:
parent
784df75e71
commit
a84eabe6e1
104
packages/filesystem/fs/etc/rc.d/trex
Normal file
104
packages/filesystem/fs/etc/rc.d/trex
Normal file
@ -0,0 +1,104 @@
|
||||
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
|
||||
return 1
|
||||
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 &
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
while [ 1 ]; do
|
||||
echo "* Stopping process..."
|
||||
killall amc > /dev/null 2>&1
|
||||
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user