license_status_check.sh #1

  • //
  • guest/
  • robert_cowham/
  • perforce/
  • sdp/
  • Maintenance/
  • license_status_check.sh
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/bin/bash
set -u

function msg () { echo -e "$*"; }
function bail () { msg "\nError: ${1:-Unknown Error}\n"; exit ${2:-1}; }

export SDP_INSTANCE=${SDP_INSTANCE:-Undefined} 
export SDP_INSTANCE=${1:-$SDP_INSTANCE} 
[[ $SDP_INSTANCE == Undefined ]] &&
    bail "\nUsage:
   ${0##*/} [SDP_INSTANCE]

   Provide an SDP_INSTANCE value (e.g. '1') as a paramter to
   this script, or use it when setting the SDP environment
   by running: source /p4/common/bin/p4_vars 1\n"

source /p4/common/bin/p4_vars "$SDP_INSTANCE"

IsLicensed=$($P4BIN -F %isLicensed% license -u)

if [[ $IsLicensed == yes ]]; then
   LicenseTimeRemaining=$($P4BIN -F %licenseTimeRemaining% license -u)

   if [[ -n "$LicenseTimeRemaining" ]]; then
     msg "License Time Remaining $((LicenseTimeRemaining/86400)) days $((LicenseTimeRemaining/3600%24)) hours $((LicenseTimeRemaining%3600/60)) minutes $((LicenseTimeRemaining%60)) seconds.\n"
   else
      bail "Could not determine licence time remaining. A call to '$P4BIN license -u' did not provide a valid response."
   fi
else
   msg "This server is not licensed."
fi
# Change User Description Committed
#1 23430 Robert Cowham Merge in changes from dev
//guest/perforce_software/sdp/dev/Maintenance/license_status_check.sh
#1 23284 C. Thomas Tyler Added Helix Core license status check script.