#!/bin/bash
PRG=GPSListener
RUNPROG=./RunProg

echo Starting $PRG

# Linking script files to bin directory
cp GPSReport ~/bin

# Running as root via sudo so that the program can set the time
(
  echo '#!/bin/sh'
  echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
  echo "export OMNIORB_CONFIG=$OMNIORB_CONFIG"
  echo "export PATH=$PATH"
  echo "export TZ=$TZ"
  echo "$PRG"
) > $RUNPROG

chmod +x $RUNPROG

# Starting the program
FULLCMD="( sudo $RUNPROG ) 2>&1 | Logger --work-dir=$HOME/log --prefix=\"$PRG\" --extension=log --max-file-size=10000000 --max-files=2 --keep-writes-together=1 &"
eval $FULLCMD

# After 10 seconds, issue start command
if false
then
  ServerExec $PRG "GPS START" &
fi

