#!/bin/bash
#------------------------------------------------------------------------------
# This script rotates the broker log file on an instance that only has the
# broker running.
#------------------------------------------------------------------------------
set -uo pipefail

# shellcheck disable=SC1091
source /p4/common/bin/backup_functions.sh
init_sdp_instance "${1:-}"

# shellcheck disable=SC1091
source /p4/common/bin/p4_vars "$SDP_INSTANCE"
# shellcheck disable=SC2034
LOGFILE="${LOGS}/broker_rotate.log"

######### Start of Script ##########

export P4PORT=1666
check_vars
set_vars
get_journalnum
rotate_last_run_logs
log "Start $P4SERVER broker log rotation."
check_uid
check_dirs
"$P4CBIN"/p4login
remove_old_logs
log "End $P4SERVER broker log rotation."

