#!/bin/bash
#
# This shell script takes care of starting and stopping
# standalone IQ Office Socket service.
#
# chkconfig: - 60 50
# description: iqoffice socket server is a application daemon, which is the program \
# that answers incoming tcp/ip socket service requests.
# Note: please update user "iqoffice" and installation path in this script.
RETVAL=0
prog="iqsocsvr"

LD_LIBRARY_PATH=/usr/local/IQ_Office/lib/LinuxIntel2.6_64bit
export LD_LIBRARY_PATH

#echo -n $"here" $prog $RETVAL

start() {
# Start daemons.
echo $"Starting Up $prog: "
RETVAL=$?
su -s /bin/sh iqoffice -c "/usr/local/IQ_Office/bin/LinuxIntel2.6_64bit/iqsocsvr -a 4000"
return $RETVAL
}

stop() {
# Stop daemons.
RETVAL=$?
su -s /bin/sh iqoffice -c "/usr/local/IQ_Office/bin/LinuxIntel2.6_64bit/iqsocsvr -x"
echo $""
return $RETVAL

}


# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 10
        start
        RETVAL=$?
        ;;
#  status)
#        status
#        RETVAL=$?
#        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $RETVAL
