#!/bin/bash
#-------------------------------------------------------------------------------
# charon_menu_VEviewlog
#-------------------------------------------------------------------------------
# Copyright (C) 2013-2023 STROMASYS.
# All rights reserved.
# Products: AXP/VAX + PAR
#-------------------------------------------------------------------------------
#
VERSION=2.0

. /opt/charon/utils/charon_common
. /opt/charon/utils/charon_common_menu

EXCODE=0
display_header "View license server log"
LOG=/opt/license-server/log/license.log

if test -s ${LOG}
then
  ask_editor
  if test -n "${EDI}"
  then
    if test -z "$(echo ${EDI}|grep vim)"
    then
      ${EDI} ${LOG} 2>/dev/null
    else
      ${EDI} -R -u ${CHARONDIR}/utils/charonlog.vimrc ${LOG} 2>/dev/null
    fi
  fi
else
  echo "Log file '${LOG}' does not exist or is empty."
  EXCODE=1
  if test ! -x /opt/license-server/license_server
  then
    echo
    echo "${FGORANGE}WARNING[0m: license server package is not installed (VE license) !"
    echo "         Please ensure you are running this utility on the license server."
    EXCODE=2
  fi
  echo
fi

echo
exit ${EXCODE:-0}
