#!/bin/sh

if [ _$XPRESS = _ ]; then
  echo "Please set the XPRESS environment variable to the location of your license file"
  exit
fi

if [ -r "$XPRESS/xpauth.ini" -o -r "$XPRESS/xpauth.xpr" ]; then
  until [ _$a = _0 ]; do
    echo "Please select the action to perform and press Enter:"
    echo "    1 - start the license manager"
    echo "    2 - stop the license manager"
    echo "    0 - quit this program"
    read a

    if [ _$a = _1 ]; then
      xpserver -xpress "$XPRESS" -logfile /var/tmp/xprl_server.log -d
      if [ $? -eq 0 ]; then
        echo "License manager started"
      fi
      break
    elif [ _$a = _2 ]; then
      xpserver -xpress "$XPRESS" -logfile /var/tmp/xprl_server.log -service stop
      break
    fi
  done

else
  echo "Cannot find the license file, xpauth.xpr. Please obtain one from"
  echo "dash and put it in the directory pointed to by the XPRESS environment"
  echo "variable: $XPRESS"
fi
