Minor tweaks

This commit is contained in:
2025-11-06 06:15:44 -05:00
parent 14b1d29384
commit c2ef3e05e3
5 changed files with 59 additions and 23 deletions

View File

@@ -16,17 +16,25 @@ get_script_dir() {
echo "$dir"
}
MYDIR=$(get_script_dir)
. $MYDIR/rbk_api.conf
. $MYDIR/rubrik.conf
. $MYDIR/oracle_funcs.ksh
usage() {
echo "Usage: $0 -d <DBNAME> -v <logs|data> -o <open|close>" 1>&2
echo "Usage: $0 -d <DBNAME> -v <logs|data> -o <open|close>"
echo " $0 -n <MV_NAME> -o <open|close>"
echo " -d Oracle DBNAME"
echo " -v Volume to operate on, logs or data"
echo " -o Operation to perform - open or close the MV"
echo " -n Specify MV name directly (use only with -o)"
exit 1
}
force=0
while getopts "d:v:o:" o; do
force=0
MVNAME=""
while getopts "d:v:o:n:" o; do
case "${o}" in
d)
DBNAME=${OPTARG}
@@ -37,6 +45,9 @@ while getopts "d:v:o:" o; do
o)
OPCODE=${OPTARG}
;;
n)
MVNAME=${OPTARG}
;;
*)
usage
;;
@@ -44,20 +55,36 @@ while getopts "d:v:o:" o; do
done
shift $((OPTIND-1))
if [ -z "${DBNAME}" ] || [ -z "${VOLUME}" ] || [ -z "${OPCODE}" ]; then
# Validate options
if [ -n "$MVNAME" ]; then
# Direct MV name mode: require -n and -o only
if [ -z "$OPCODE" ]; then
usage
fi
mv_name="$MVNAME"
elif [ -n "$DBNAME" ] && [ -n "$VOLUME" ] && [ -n "$OPCODE" ]; then
# Standard mode: require -d, -v, -o
mv_name=$(get_short_hostname)_${DBNAME}_${VOLUME}
else
usage
fi
# Script starts here
get_short_hostname() {
if hostname -s >/dev/null 2>&1; then
hostname -s
else
# Check OS type first - HP-UX hostname doesn't support -s
os_type=$(uname -s)
if [ "$os_type" = "HP-UX" ]; then
hostname | awk -F. '{print $1}'
else
# Try -s flag on other systems
if hostname -s >/dev/null 2>&1; then
hostname -s
else
hostname | awk -F. '{print $1}'
fi
fi
}
mv_name=$(get_short_hostname)_${DBNAME}_${VOLUME}
get_mv
case $OPCODE in