#!/bin/bash
#echo call with $1

if [[ -n "$1" ]]; then
    java -jar licensemanager.jar eval get $1 requestinstallation
else
    type X #check for X terminal is available.
    res=$?
    if [[ "$res" > 0 ]]; then
      echo "***************************************"
      echo NO  WINDOW ENVIRONMENT. You must license manually.
      echo Run the following to install an eval license with your email:
      echo " > cd node_modules/ocr && npm run register -- youremail@domain.com"
      exit 0
    fi
    java -jar licensemanager.jar
fi
res=$?
if [[ "$res" > 1 ]]; then
    echo "***************************************"
    echo The license manager failed to install a license.
    echo  If you already have a license installed, then you can ignore this message. Otherwise,
    echo Run the following to display the license manager:
    echo " > cd node_modules/ocr && npm run register"
    echo "Run the following to install an eval license with your email"
    echo " > cd node_modules/ocr && npm run register -- youremail@domain.com"
    echo "***************************************"
fi
exit 0
