awips2/cave/build/static/linux/alertviz/alertviz.sh
Steven Harris 9c67bbab77 12.11.1-1 baseline
Former-commit-id: ffe3641057 [formerly 0e86bfd1d3] [formerly 618aa3f316] [formerly feec28f274 [formerly 618aa3f316 [formerly 765055b5332ddace3cec2d07e279652de869cfe4]]]
Former-commit-id: feec28f274
Former-commit-id: 5951ea0cd95d43633ba501132c7b65a55db27e09 [formerly 8843ffd022]
Former-commit-id: f5e63d5f93
2012-09-27 15:57:45 -05:00

113 lines
2.8 KiB
Bash

#!/bin/bash
# Alert VIZ Startup Script
# Note: Alert VIZ will not run as 'root'
user=`/usr/bin/whoami`
if [ ${user} == 'root' ]; then
echo "WARNING: Alert VIZ cannot be run as user '${user}'!"
echo " change to another user and run again."
exit 1
fi
# We will no longer be using hard-coded paths that need to be replaced.
# Use rpm to find the paths that we need.
JAVA_INSTALL="/awips2/java"
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "ERROR: awips2-java Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
fi
PYTHON_INSTALL="/awips2/python"
RC="$?"
if [ ! "${RC}" = "0" ]; then
echo "ERROR: awips2-python Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
fi
ALERTVIZ_INSTALL="/awips2/alertviz"
path_to_script=`readlink -f $0`
dir=$(dirname $path_to_script)
export AWIPS_INSTALL_DIR=${ALERTVIZ_INSTALL}
export LD_LIBRARY_PATH=${JAVA_INSTALL}/lib:${PYTHON_INSTALL}/lib:$LD_LIBRARY_PATH
export LD_PRELOAD=${PYTHON_INSTALL}/lib/libpython2.7.so
export PATH=${JAVA_INSTALL}/bin:${PYTHON_INSTALL}/bin:$PATH
export JAVA_HOME="${JAVA_INSTALL}/jre"
exitVal=1
#check for gtk-2.0 value
gtkResource=.gtkrc-2.0
includeLine="include \"$HOME/.gtkrc.mine\""
mineFile=.gtkrc.mine
altButtonLine="gtk-alternative-button-order=1"
if [ -f $HOME/$gtkResource ]; then
if [ -w $HOME/$gtkResource ]; then
var=`grep "gtkrc.mine" $HOME/$gtkResource`
if [ '' == "$var" ]; then
echo $includeLine >> $HOME/$gtkResource
fi
fi
else
touch $HOME/$gtkResource
echo $includeLine >> $HOME/$gtkResource
fi
if [ -f $HOME/$mineFile ]; then
if [ -w $HOME/$mineFile ]; then
var=`grep "alternative-button-order" $HOME/$mineFile`
if [ '' == "$var" ]; then
echo $altButtonLine >> $HOME/$mineFile
fi
fi
else
touch $HOME/$mineFile
echo $altButtonLine >> $HOME/$mineFile
fi
#check for the logs directory, which may not be present at first start
hostName=`hostname -s`
LOGDIR=$HOME/caveData/logs/consoleLogs/$hostName/
if [ ! -d $LOGDIR ]; then
mkdir -p $LOGDIR
fi
# Special instructions for the 64-bit jvm.
ARCH_ARGS=""
if [ -f /awips2/java/jre/lib/amd64/server/libjvm.so ]; then
ARCH_ARGS="-vm /awips2/java/jre/lib/amd64/server/libjvm.so"
fi
#run a loop for alertviz
while [ $exitVal -ne 0 ]
do
curTime=`date +%Y%m%d_%H%M%S`
LOGFILE=${LOGDIR}/alertviz_${curTime}_console.log
export LOGFILE_ALERTVIZ=${LOGDIR}/alertviz_${curTime}_admin.log
#first check if we can write to the directory
if [ -w ${LOGDIR} ]; then
touch ${LOGFILE}
fi
#check for display; if no display then exit
if [ -z "${DISPLAY}" ]; then
echo "Display is not available."
exitVal=0
else
#finally check if we can write to the file
if [ -w ${LOGFILE} ]; then
${dir}/alertviz ${ARCH_ARGS} $* > ${LOGFILE} 2>&1
else
${dir}/alertviz ${ARCH_ARGS} $*
fi
fi
exitVal=$?
done