#!/bin/sh
# Copyright (c) 1997-2003 by ilink Kommunikationssysteme GmbH.  All Rights Reserved.
#
# Start/stop TeamCall LinkV24
#
# Calling user has to be root!
# Modify according to your needs.
# Set CTIDIR to your TeamCall installation directory.
# Set -c configuration file to a valid value (see documentation)!
#

CTIDIR=/usr/local/CSTAServer
# set "/usr/local/CSTAServer" to actual installation directory path
# example: CTIDIR=/opt/ilink/CSTAServer

SERVER=CSTALinkV24
SERVERNAME="CTI LinkV24"

case $1 in
start)
    if [ x`uname` != xLinux -a x`uname` != xSunOS -a x`uname` != xUNIX_SV ]; then
        echo "unsupported OS";
        exit 0;
    fi
    if [ -f "$CTIDIR/$SERVER" ]; then
        "$CTIDIR/$SERVER" -c "$CTIDIR/Default.conf" 2> /dev/null 1>&2 &
        echo "$SERVERNAME started."
    else
        echo "$SERVERNAME NOT started."
    fi
    ;;
stop)
    PATH=/usr/5bin:/bin:/usr/bin:/usr/sbin:$PATH
    pid=x;
    if [ x`uname` = xSunOS -o x`uname` = xUNIX_SV ]; then
        pid=`ps -ef | grep -v grep | grep "$CTIDIR/$SERVER" | awk '{ print $2 }'`;
        if [ x != "x$pid" ]; then
            kill $pid
        fi
    elif [ x`uname` = xLinux ]; then
        killall "$SERVER"
    else
        echo "unsupported OS";
        exit 0;
    fi
    ;;
*)
    echo "Invalid argument: " $1
    ;;
esac

exit 0
