#!/bin/sh
#-------------------------------------------------------------------------------
# charon_menu_aksusbd
#-------------------------------------------------------------------------------
# Copyright (C) 2013-2022 STROMASYS.
# All rights reserved.
#
#-------------------------------------------------------------------------------
#
VERSION=1.5

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

while test 1
do
  display_header "License driver management (aksusbd)"
  echo
  if test `id -u` -ne 0
  then
    tput bold
    echo "Must be root !"
    tput sgr0
    Press_Enter
    echo
    break
  fi

  display_licfound full

  tput bold
  echo "Driver service status:"
  tput sgr0
  /usr/bin/systemctl --lines 0 status aksusbd
  /usr/bin/systemctl -q is-enabled aksusbd
  if test $? -ne 0
  then
    tput bold
    echo "Service is not enabled. Enabling it now..."
    tput sgr0
    /usr/bin/systemctl enable aksusbd
  fi
  echo

  while test 1
  do
    echo -n "Do you want to restart the service (y/n) (q to quit) ? "
    read ANS
    case "${ANS}"
    in
      y|Y)
        /usr/bin/systemctl restart aksusbd
        break
        ;;
      n|N|q|Q)
        break 2
        ;;
      *)
        break
        ;;
    esac
  done
done

exit
