Compare commits

..

No commits in common. "main" and "check-and-fix-permissions" have entirely different histories.

2 changed files with 49 additions and 186 deletions

View File

@ -49,6 +49,55 @@ HELP
exit 0
}
################################################################################
# Argument parser
################################################################################
die() {
printf '%s\n' "$1" >&2
exit 1
}
while :; do
case $1 in
-h|-\?|--help)
show_help # Display a usage synopsis.
exit
;;
-r|--repo)
if [ "$2" ]; then
REPO=$2
shift
else
die 'ERROR: "-r|--repo" requires a non-empty option argument.'
fi
;;
-m|--mode)
if [ "$2" ]; then
MODE=$2
shift
else
die 'ERROR: "-r|--repo" requires a non-empty option argument.'
fi
;;
-t|--timeout)
if [ "$2" ]; then
TIMEOUT=$2
shift
else
die 'ERROR: "-t|--timeout" requires a non-empty option argument.'
fi
;;
--) # End of all options.
shift
break
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done
get_bricks() {
MY_HOSTNAME=$(echo "${HOSTNAME}" | cut -d '.' -f 1)
if ! BRICKS=$(gluster vol info "${REPO}" | grep -i "${MY_HOSTNAME}" | grep -o 'brick[0-9]\+'); then
@ -108,56 +157,6 @@ scan_paths() {
done
}
################################################################################
# Argument parser
################################################################################
die() {
printf '%s\n' "$1" >&2
exit 1
}
while :; do
case $1 in
-h|-\?|--help)
show_help # Display a usage synopsis.
exit
;;
-r|--repo)
if [ "$2" ]; then
REPO=$2
shift
else
die 'ERROR: "-r|--repo" requires a non-empty option argument.'
fi
;;
-m|--mode)
if [ "$2" ]; then
MODE=$2
shift
else
die 'ERROR: "-r|--repo" requires a non-empty option argument.'
fi
;;
-t|--timeout)
if [ "$2" ]; then
TIMEOUT=$2
shift
else
die 'ERROR: "-t|--timeout" requires a non-empty option argument.'
fi
;;
--) # End of all options.
shift
break
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done
################################################################################
# Main Main Main
################################################################################

View File

@ -1,136 +0,0 @@
#!/bin/bash
if ! [ "${LOGNAME}" == "root" ]; then
echo "Please run this script as root or with sudo..."
exit 1
fi
################################################################################
# Global variables
################################################################################
################################################################################
# Functions
################################################################################
show_help() {
cat << HELP
Script to help around ssacli and automate things...
Usage: $1 [OPTION]
Mandatory:
Optionial:
-a|--array-info ARRAY_INFO Info about arrays and how much free
space they provide
-l|--ld LD_INFO Info about logical drives
-p|--pd PD_INFO Info about physical drives
HELP
exit 0
}
get_controllers() {
CONTROLLERS=$(ssacli ctrl all show | grep -o 'Slot\ [0-9]\+' | cut -d ' ' -f 2)
}
get_array_free_space() {
for CONTROLLER in ${CONTROLLERS}; do
header2 "Controller slot=${CONTROLLER}"
ssacli ctrl slot=${CONTROLLER} array all show | sed -e '/^$/d'
echo ""
done
}
get_logical_drives() {
for CONTROLLER in ${CONTROLLERS}; do
header2 "Controller slot=${CONTROLLER}"
ssacli ctrl slot=${CONTROLLER} ld all show | sed -e '/^$/d'
echo ""
done
}
get_physical_drives() {
for CONTROLLER in ${CONTROLLERS}; do
header2 "Controller slot=${CONTROLLER}"
ssacli ctrl slot=${CONTROLLER} pd all show | sed -e '/^$/d'
echo ""
done
}
header1() {
cat << HEADER1
################################################################################
# ${@}
################################################################################
HEADER1
}
header2() {
cat << HEADER2
# ${@}
HEADER2
}
################################################################################
# Argument parser
################################################################################
die() {
printf '%s\n' "$1" >&2
exit 1
}
while :; do
case $1 in
-h|-\?|--help)
show_help # Display a usage synopsis.
exit
;;
-a|--array-info)
ARRAY_INFO=true
;;
-l|--ld)
LD_INFO=true
;;
-p|--pd)
PD_INFO=true
;;
--) # End of all options.
shift
break
;;
*) # Default case: No more options, so break out of the loop.
break
esac
shift
done
################################################################################
# Main Main Main
################################################################################
if ! get_controllers; then
echo "Could not get list of controllers..."
exit 1
fi
if [ "${ARRAY_INFO}" == "true" ]; then
header1 "Array Infos"
get_array_free_space
echo ""
fi
if [ "${LD_INFO}" == "true" ]; then
header1 "Logical Drive Infos"
get_logical_drives
echo ""
fi
if [ "${PD_INFO}" == "true" ]; then
header1 "Physical Drive Infos"
get_physical_drives
echo ""
fi