EOF
)
+detect_color
+
#------------------------------------------------------------------------------
usage() {
cat <<-EOF
exit 2
fi
- check_for_root
-
- LOGFILE="/var/log/${BASE_NAME}.log"
+ LOGFILE="${MC_ROOT_DIR}/${BASE_NAME}.log"
}
done
for folder in "${MC_BACKUP_DIR}" "${MC_SERVER_DIR}" ; do
- debug "Checking for directory '${folder}' ..."
+ debug "Checking for directory '${CYAN}${folder}${NORMAL}' ..."
if [[ ! -d "${folder}" ]]; then
all_ok="n"
error "Did not found directory '${RED}${folder}${NORMAL}'."
VERSION="0.4.0"
-STD_SHORT_OPTIONS="sdvhV"
-STD_LONG_OPTIONS="simulate,debug,verbose,nocolor,help,version"
+STD_SHORT_OPTIONS="sdvqhV"
+STD_LONG_OPTIONS="simulate,debug,verbose,quiet,nocolor,help,version"
STD_USAGE_MSG=$( cat <<-EOF
-s|--simulate Simulation mode - dont apply any changes.
-d|--debug Debug output (bash -x).
-v|--verbose Set verbosity on.
+ Mutually exclusive to '--quiet'.
+ -q|--quiet Quiet mode, no output except errors.
+ Mutually exclusive to '--verbose'.
--nocolor Dont use colors on display.
-h|--help Show this output and exit.
-V|--version prints out version number of the script and exit
DEBUG="n"
DO_ASK="n"
SIMULATE="n"
+QUIET="n"
LOGFILE=
VERBOSE="y"
shift
;;
+ -q|--quiet)
+ QUIET="y"
+ shift
+ ;;
--nocolor)
RED=""
YELLOW=""
done
fi
+ if [[ "${VERBOSE}" == "y" && "${QUIET}" == "y" ]] ; then
+ error "The options '${RED}--verbose${NORMAL}' and '${RED}--quiet${NORMAL}' are mutually exclusive."
+ echo
+ usage >&2
+ exit 1
+ fi
+
if [[ "${DEBUG}" = "y" ]] ; then
set -x
fi
if [[ -n "${LOGFILE}" ]] ; then
echo -e "[${ts}] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >>"${LOGFILE}"
fi
- echo -e " ${GREEN}*${NORMAL} [${ts}] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >&2
+ if [[ "${QUIET}" != "y" ]] ; then
+ echo -e " ${GREEN}*${NORMAL} [${ts}] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >&2
+ fi
}
#------------------------------------------------------------------------------