Alignment, restructuring, and quoting of -? option

This commit is contained in:
Michael Boelen 2016-05-11 15:12:37 +02:00
parent 50609242c2
commit 668a1fd0e5
1 changed files with 176 additions and 180 deletions

View File

@ -23,6 +23,9 @@
#################################################################################
#
echo $#
echo $@
# Check number of parameters submitted (at least one is needed)
PARAMCOUNT=$#
while [ $# -ge 1 ]; do
@ -114,213 +117,206 @@
fi
;;
# Assign auditor to report
--auditor)
shift
AUDITORNAME=$1
;;
# Assign auditor to report
--auditor)
shift
AUDITORNAME=$1
;;
# Perform tests (deprecated, use audit system)
-c | --check-all | --checkall)
# echo "Usage of option -c is deprecated. Please use: lynis audit system [options]"
CHECK=1
;;
# Perform tests (deprecated, use audit system)
--check-all | --checkall | -c)
# echo "Usage of option -c is deprecated. Please use: lynis audit system [options]"
CHECK=1
;;
# Cronjob support
--cronjob | --cron)
CRONJOB=1;
# Use some defaults (-c, -Q, no colors)
CHECK=1; QUICKMODE=1; NEVERBREAK=1
# Get rid of the colors
NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
;;
# Cronjob support
--cronjob | --cron)
CRONJOB=1
CHECK=1; QUICKMODE=1; NEVERBREAK=1 # Use some defaults (-c, -Q, no colors)
NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED="" # Remove colors
;;
# Perform tests with additional debugging information on screen
--debug)
DEBUG=1
;;
# Perform tests with additional debugging information on screen
--debug)
DEBUG=1
;;
# Developer mode (more details when creating tests)
--developer)
DEVELOPER_MODE=1
;;
# Developer mode (more details when creating tests)
--developer)
DEVELOPER_MODE=1
;;
# Display all available options with short alias
--dump-options | --dumpoptions)
OPTIONS="--auditor
--check-all_(-c) --config --cronjob_(--cron)
--debug
--help_(-h)
--info
--license-key --log-file
--manpage_(--man)
--no-colors --no-log
--pentest --profile --plugins-dir
--quiet_(-q) --quick_(-Q)
--report-file --reverse-colors
--tests --tests-category
--upload
--version_(-V) --view-categories"
for I in ${OPTIONS}; do
echo "${I}" | tr '_' ' '
done
ExitClean
;;
# View help
--help | -h | -?)
VIEWHELP=1
;;
# Display all available options with short alias
--dump-options | --dumpoptions)
OPTIONS="--auditor
--check-all_(-c) --config --cronjob_(--cron)
--debug
--help_(-h)
--info
--license-key --log-file
--manpage_(--man)
--no-colors --no-log
--pentest --profile --plugins-dir
--quiet_(-q) --quick_(-Q)
--report-file --reverse-colors
--tests --tests-category
--upload
--version_(-V) --view-categories"
for I in ${OPTIONS}; do
echo "${I}" | tr '_' ' '
done
ExitClean
;;
# View program/database information
--check-update | --check-updates | --info)
echo "This option is deprecated"
echo "Use: lynis update info"
ExitClean
;;
# View help
--help | -h | "-?")
VIEWHELP=1
;;
# License key for Lynis Enterprise
--license-key)
shift
LICENSE_KEY=$1
;;
# View program/database information
--check-update | --check-updates | --info)
echo "This option is deprecated"
echo "Use: lynis update info"
ExitClean
;;
# Adjust default logfile location
--logfile | --log-file)
shift
LOGFILE=$1
;;
# License key for Lynis Enterprise
--license-key)
shift
LICENSE_KEY=$1
;;
# Don't use colors
--no-colors | --nocolors)
NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
;;
# Adjust default logfile location
--logfile | --log-file)
shift
LOGFILE=$1
;;
# Disable logging
--no-log | --nolog)
LOGFILE="/dev/null"
;;
# Don't use colors
--no-colors | --nocolors)
NORMAL=""; WARNING=""; SECTION=""; NOTICE=""; OK=""; BAD=""; CYAN=""; MAGENTA=""; PURPLE=""; YELLOW=""; WHITE=""; GREEN=""; RED=""
;;
--pentest | --pen-test)
PENTESTINGMODE=1
;;
# Disable logging
--no-log | --nolog)
LOGFILE="/dev/null"
;;
# Define a custom profile file
--profile)
shift
SEARCH_PROFILES=$1
;;
--pen-test | --pentest)
PENTESTINGMODE=1
;;
# Define a custom plugin directory
--plugindir | --plugin-dir | --plugins-dir)
shift
PLUGINDIR=$1
LASTCHAR=`echo $1 | awk '{ print substr($0, length($0))}'`
if [ "${LASTCHAR}" = "/" ]; then
echo "${RED}Error:${WHITE} plugin directory path should not end with a slash${NORMAL}"
ExitCustom 65
fi
if [ ! -d ${PLUGINDIR} ]; then
echo "${RED}Error:${WHITE} invalid plugin directory ${PLUGINDIR}${NORMAL}"
ExitCustom 66
fi
;;
# Define a custom profile file
--profile)
shift
SEARCH_PROFILES=$1
;;
# Quiet mode
-q | --quiet)
QUIET=1
# Run non-interactive
QUICKMODE=1
;;
# Define a custom plugin directory
--plugindir | --plugin-dir | --plugins-dir)
shift
PLUGINDIR=$1
LASTCHAR=`echo $1 | awk '{ print substr($0, length($0))}'`
if [ "${LASTCHAR}" = "/" ]; then
echo "${RED}Error:${WHITE} plugin directory path should not end with a slash${NORMAL}"
ExitCustom 65
fi
if [ ! -d ${PLUGINDIR} ]; then
echo "${RED}Error:${WHITE} invalid plugin directory ${PLUGINDIR}${NORMAL}"
ExitCustom 66
fi
;;
# Non-interactive mode
-Q | --quick)
QUICKMODE=1
;;
# Quiet mode
--quiet | -q)
QUIET=1
QUICKMODE=1 # Run non-interactive
;;
# Define alternative report file
--report-file)
shift
REPORTFILE=$1
;;
# Non-interactive mode
--quick | -Q)
QUICKMODE=1
;;
# Strip the colors which aren't clearly visible on light backgrounds
--reverse-colors)
#NORMAL="";
SECTION="${NORMAL}";
NOTICE="${NORMAL}";
#OK="";
#BAD="";
CYAN="${NORMAL}";
GREEN="${NORMAL}";
YELLOW="${NORMAL}";
WHITE="${NORMAL}";
PURPLE="${NORMAL}";
#GREEN="";
#RED=""
;;
# Define alternative report file
--report-file)
shift
REPORTFILE=$1
;;
# Skip execution of plugins
--skip-plugins | --no-plugins)
RUN_PLUGINS=0
;;
# Strip the colors which aren't clearly visible on light backgrounds
--reverse-colors)
SECTION="${NORMAL}";
NOTICE="${NORMAL}";
CYAN="${NORMAL}";
GREEN="${NORMAL}";
YELLOW="${NORMAL}";
WHITE="${NORMAL}";
PURPLE="${NORMAL}";
;;
# Only scan these tests
--tests)
shift
TESTS_TO_PERFORM=$1
;;
# Skip execution of plugins
--skip-plugins | --no-plugins)
RUN_PLUGINS=0
;;
# Scan one or more categories only
--tests-category)
shift
TESTS_CATEGORY_TO_PERFORM=$1
;;
# Only scan these tests
--tests)
shift
TESTS_TO_PERFORM=$1
;;
# Lynis Enterprise: upload data to central node
--upload)
UPLOAD_DATA=1
;;
# Scan one or more categories only
--tests-category)
shift
TESTS_CATEGORY_TO_PERFORM=$1
;;
--verbose)
VERBOSE=1
;;
# Lynis Enterprise: upload data to central node
--upload)
UPLOAD_DATA=1
;;
# Version number
-V | --version)
echo "${PROGRAM_VERSION}"
exit 0
;;
--verbose)
VERBOSE=1
;;
--view-categories | --list-categories | --show-categories)
ViewCategories
exit 0
;;
# Version number
--version | -V)
echo "${PROGRAM_VERSION}"
exit 0
;;
# View man page
--view-manpage | --man | --manpage)
if [ -f lynis.8 ]; then
nroff -man lynis.8
exit 0
else
echo "Error: man page file not found (lynis.8)"
echo "If you are running an installed version of Lynis, use 'man lynis'"
exit 1
fi
;;
--view-categories | --list-categories | --show-categories)
ViewCategories
exit 0
;;
# Warnings
--warnings-only | --show-warnings-only)
SHOW_WARNINGS_ONLY=1
QUICKMODE=1
QUIET=1
;;
# View man page
--view-manpage | --man | --manpage)
if [ -f lynis.8 ]; then
nroff -man lynis.8
exit 0
else
echo "Error: man page file not found (lynis.8)"
echo "If you are running an installed version of Lynis, use 'man lynis'"
exit 1
fi
;;
# Drop out when using wrong option(s)
*)
# Wrong option used, we bail out later
WRONGOPTION=1
WRONGOPTION_value=$1
;;
# Warnings
--warnings-only | --show-warnings-only)
SHOW_WARNINGS_ONLY=1
QUICKMODE=1
QUIET=1
;;
# Drop out when using wrong option(s)
*)
# Wrong option used, we bail out later
WRONGOPTION=1
WRONGOPTION_value=$1
;;
esac
shift