Hacked By AnonymousFox

Current Path : /sbin/
Upload File :
Current File : //sbin/clnreg_ks

#!/bin/bash

# author: Vasiliy Kleschov <vkleschov@cloudlinux.com>
# created: 2018-03-14
# CloudLinux IP registration tool

SKIP_RHNCHECK=0
SHOW_HELP=0
SYSTEMID_FILE="/etc/sysconfig/rhn/systemid"
LOG_FILE="/var/log/up2date"

# simple cycle that does not meant to do
# some completed stuff like positional arguments
# if you need something more -> rewrite this script in python
for opt in "$@"
do
    case "$opt" in
        --force) SKIP_RHNCHECK=1
            ;;
        --help|-h) SHOW_HELP=1
            ;;
        --activationkey=*|--activationkey)
            ;;
        --edition=*|--edition)
            ;;
    esac
done

# we should show help even if license exists
if [[ ${SHOW_HELP} == 1 ]]; then
    /usr/sbin/rhnreg_ks --help
    exit $?
fi;

# the meaning of the following checks is:
# 1. to run ip registration on first yum-rhn-plugin
#    activation (probably right after vm boot)
# 2. to fix ip license if some template contains
#    systemid file for no reason (that is error 9 from CLN)
# but don't change license if cln is just down

# if systemid does not exist it means we don't have
# license yet and not reason to call rhn_check (it will fail anyway)
if [[ -f "${SYSTEMID_FILE}" ]]; then
  # skip rhn_check only with --force option passed
  if [[ ${SKIP_RHNCHECK} == 0 ]]; then
      result=$(rhn_check 2>&1)
      rc=$?
      if [[ "${rc}" = "0" ]]; then
          echo "Command rhn_check exited with code zero." \
               "That usually means that registration is not needed." \
               "Use --force to override"
          exit 0
      elif [[ "${result}" =~ "Invalid System Credentials" ]]; then
          # we get and error meaning that systemid of server is
          # no longer valid for server-side application
          # in this case we can try obtaining new license
          echo "${result}" >> "${LOG_FILE}"
          echo "Seems like server is missing license. Trying to get new one using IP licensing flow." | tee -a "${LOG_FILE}"
      else
          echo "${result}" | tee -a "${LOG_FILE}"
          echo "Unable to check license status and register server." \
               "Use --force to override"
          exit $rc
      fi;
  fi;
else
  echo "Server does not have active license yet. Trying to get one using IP licensing flow."
fi

/usr/sbin/rhnreg_ks --activationkey=IPL --force $@

Hacked By AnonymousFox1.0, Coded By AnonymousFox