#!/bin/bash # This script will run a pulp command to update consumers and reboot them CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BOOTSTRAP=${CURR_DIR}/bootstrap.sh # Arguments that require values declare -A arr_args_req_value=() ####################################### function usage { echo "Usage: ${0}" echo " --consumer-group-id" echo " Pulp consumer group id" echo " -r | --reboot" echo " Should the consumer require reboot after update" echo " -h | --help" echo " Show this usage" exit 0 } if [ ! -e ${BOOTSTRAP} ];then echo 'EXITING: boostrap.sh must be in the same directory as this script' exit 1 fi . $BOOTSTRAP # Check command line if [[ -z "${@}" ]]; then usage fi echo "${@}" | grep 'consumer-group-id' > /dev/null if [ $? != 0 ]; then echo 'Error: A consumer group id is required!' exit fi # Process command line arguments arr_args_req_value['consumer-group-id']=true while [[ $# > 0 ]]; do key="$1" case $key in --consumer-group-id) check_values arr_args_req_value 'consumer-group-id' 'A consumer group id is required' "$2" _consumer_group_id=$2 shift;; -r|--reboot) reboot_arg='--reboot' shift;; -h|--help) usage shift;; *) _default=$key shift;; esac done pulp-admin rpm consumer group package update --consumer-group-id=${_consumer_group_id} --all $reboot_arg