license_status_check.sh #2

  • //
  • guest/
  • perforce_software/
  • sdp/
  • main/
  • Unsupported/
  • 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 parameter 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 license 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
#2 27761 C. Thomas Tyler Released SDP 2020.1.27759 (2021/05/07).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#1 27331 C. Thomas Tyler Released SDP 2020.1.27325 (2021/01/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
//guest/perforce_software/sdp/dev/Unsupported/Maintenance/license_status_check.sh
#1 26652 Robert Cowham This is Tom's change:

Introduced new 'Unsupported' directory to clarify that some files
in the SDP are not officially supported. These files are samples for
illustration, to provide examples, or are deprecated but not yet
ready for removal from the package.

The Maintenance and many SDP triggers have been moved under here,
along with other SDP scripts and triggers.

Added comments to p4_vars indicating that it should not be edited
directly. Added reference to an optional site_global_vars file that,
if it exists, will be sourced to provide global user settings
without needing to edit p4_vars.

As an exception to the refactoring, the totalusers.py Maintenance
script will be moved to indicate that it is supported.

Removed settings to support long-sunset P4Web from supported structure.

Structure under new .../Unsupported folder is:
   Samples/bin             Sample scripts.
   Samples/triggers        Sample trigger scripts.
   Samples/triggers/tests  Sample trigger script tests.
   Samples/broker          Sample broker filter scripts.
   Deprecated/triggers     Deprecated triggers.

To Do in a subsequent change: Make corresponding doc changes.
//guest/perforce_software/sdp/dev/Maintenance/license_status_check.sh
#1 23284 C. Thomas Tyler Added Helix Core license status check script.