Check for number of arguments

This commit is contained in:
Michael Boelen 2016-07-28 11:10:59 +02:00
parent f498d7bf2c
commit db5d825701

View File

@ -33,7 +33,7 @@
HELPER="audit" HELPER="audit"
SKIP_PLUGINS=1 SKIP_PLUGINS=1
RUN_TESTS=0 RUN_TESTS=0
if [ ! $2 = "" ]; then if [ $# -gt 1 ]; then
case $2 in case $2 in
"dockerfile") "dockerfile")
if [ "$3" = "" ]; then if [ "$3" = "" ]; then
@ -48,33 +48,35 @@
fi fi
;; ;;
"system") "system")
if [ "$3" = "remote" ]; then if [ $# -gt 2 ]; then
shift if [ "$3" = "remote" ]; then
if [ "$3" = "" ]; then shift
echo "${RED}Error: ${WHITE}Missing remote location${NORMAL}" if [ "$3" = "" ]; then
echo "Example: $0 audit system remote 192.168.1.100" echo "${RED}Error: ${WHITE}Missing remote location${NORMAL}"
ExitFatal echo "Example: $0 audit system remote 192.168.1.100"
else ExitFatal
REMOTE_TARGET="$3" else
shift; shift; shift # shift out first three arguments REMOTE_TARGET="$3"
EXTRA_PARAMS="" shift; shift; shift # shift out first three arguments
if [ ! "$1" = "" ]; then EXTRA_PARAMS=" $@"; fi EXTRA_PARAMS=""
# --quick is added to be non-interactive if [ ! "$1" = "" ]; then EXTRA_PARAMS=" $@"; fi
REMOTE_COMMAND="./lynis audit system --quick${EXTRA_PARAMS}" # --quick is added to be non-interactive
echo "" REMOTE_COMMAND="./lynis audit system --quick${EXTRA_PARAMS}"
echo " How to perform a remote scan:" echo ""
echo " =============================" echo " How to perform a remote scan:"
echo " Target : ${REMOTE_TARGET}" echo " ============================="
echo " Command : ${REMOTE_COMMAND}" echo " Target : ${REMOTE_TARGET}"
HELPER="system_remote_scan" echo " Command : ${REMOTE_COMMAND}"
HELPER_PARAMS="$@" HELPER="system_remote_scan"
CHECK_BINARIES=0 HELPER_PARAMS="$@"
QUIET=1 CHECK_BINARIES=0
RUN_HELPERS=1 QUIET=1
SKIP_PLUGINS=1 RUN_HELPERS=1
RUN_TESTS=0 SKIP_PLUGINS=1
SHOW_PROGRAM_DETAILS=0 RUN_TESTS=0
break SHOW_PROGRAM_DETAILS=0
break
fi
fi fi
fi fi
CHECK=1 CHECK=1
@ -83,6 +85,7 @@
SKIP_PLUGINS=0 SKIP_PLUGINS=0
RUN_TESTS=1 RUN_TESTS=1
shift shift
;; ;;
esac esac
else else