Aprica_Start.sh


max21 Unternehmensgruppe
#!/bin/sh
ulimit -c 4194304
// unlimited stacksize sonst absturz beim parsen der terrorliste
ulimit -s unlimited
usage()
{
	echo "Usage: $0 --mandant=... [--debug|--instance=(0-9)] [--demo] [--batch] [--secure]"
	echo mandant muss eine 6 stellige Zahl sein, z.B. 000100
	exit
}
instance=1
while test $# -gt 0; do
    case "$1" in
      -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
         ;;
      *) optarg= 
         ;;
    esac
    case "$1" in
	--mandant=*)
	INTARS_MANDANT=$optarg
	echo mandant=$INTARS_MANDANT
	;;
	
    --instance=*)
      instance=$optarg
      echo instance=$instance
      ;;
    --debug)
      gdb=yes
      echo debug
      ;;
    --secure)
      secure=yes
      echo secure
      ;;
    --batch=*)
      batch=yes
	  batch_script=$optarg
	  instance=99
      echo batch
      ;;
    --version)
      echo 5.1
      exit 0
      ;;
    --help)
      usage
      ;;
    *)
      usage
      ;;
    esac
    shift
done
# require mandant
if [ -z "$INTARS_MANDANT" ] ; then
	usage
fi
INTARS_MANDANT_L=`(echo -n "$INTARS_MANDANT"|wc -c|tr -d [:space:])`
if [ "$INTARS_MANDANT_L" != "6" ] ; then
	usage
fi
DATE=`date +"%Y%m%d%H%M"`
umask 0000
shopt -s huponexit
. /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
LOGFILE=$GNUSTEP_LOCAL_ROOT/Library/Aprica2/_K_$INTARS_MANDANT/Resources/Logs/log_${instance}.txt
LOGFILE_OLD=$GNUSTEP_LOCAL_ROOT/Library/Aprica2/_K_$INTARS_MANDANT/Resources/Logs/log_${instance}_bis_$DATE.txt
mv $LOGFILE $LOGFILE_OLD
date > $LOGFILE
chmod a+rw $LOGFILE
if [ "$debug" = "yes" ] ; then
  INTARS_APP=$GNUSTEP_LOCAL_ROOT/GSWApps/Aprica2.debug/Aprica2
  INTARS_OPTIONS="--GNU-Debug=NoWarn -GSWMTEnabled NO -WOHost localhost -WODebuggingEnabled NO -WOStatusDebuggingEnabled NO -WOStatusLoggingEnabled NO -n $instance"
else
  INTARS_APP=$GNUSTEP_LOCAL_ROOT/GSWApps/Aprica2.gswa/Aprica2
  INTARS_OPTIONS="--GNU-Debug=NoWarn -GSWMTEnabled NO -WOHost localhost -WODebuggingEnabled NO -WOStatusDebuggingEnabled NO -WOStatusLoggingEnabled NO -n $instance"
fi
if [ "$batch" = "yes" ] ; then
	INTARS_OPTIONS=$INTARS_OPTIONS" -batch"
    INTARS_OPTIONS=$INTARS_OPTIONS" $batch_script"
fi 
if [ "$secure" = "yes" ] ; then
	INTARS_OPTIONS=$INTARS_OPTIONS" -secure"
fi 
env >> $LOGFILE
# copy binary 
rm -f $INTARS_APP$INTARS_MANDANT
cp $INTARS_APP $INTARS_APP$INTARS_MANDANT
echo -n "Application started: " >> $LOGFILE
date >> $LOGFILE
if [ "$gdb" = "yes" ] ; then
  echo $INTARS_APP$INTARS_MANDANT $INTARS_OPTIONS | tee -a $LOGFILE
  gdb --args $INTARS_APP$INTARS_MANDANT $INTARS_OPTIONS
else
  echo $INTARS_APP$INTARS_MANDANT $INTARS_OPTIONS | tee -a $LOGFILE
  $INTARS_APP$INTARS_MANDANT $INTARS_OPTIONS 2>&1 | tee -a $LOGFILE
fi
echo -n "Application ended: " >> $LOGFILE
date >> $LOGFILE
exit 0
Foto