Changed how arguments are passed to magellan.sh script

This commit is contained in:
David J. Allen 2023-10-24 14:33:32 -06:00
parent 091045ad1e
commit e039099263

View file

@ -11,6 +11,8 @@ THREADS="1"
TIMEOUT="30"
ARGS=""
FORCE_UPDATE=false
SCAN_PARAMS=""
COLLECT_PARAMS=""
function build(){
@ -19,11 +21,11 @@ function build(){
function scan() {
# ./magellan scan --subnet 172.16.0.0 --port 443
${EXE} scan \
--subnet ${SUBNETS} \
--port ${PORTS} \
--timeout ${TIMEOUT} \
--threads ${THREADS}
${EXE} scan ${SCAN_PARAMS}
# --subnet ${SUBNETS} \
# --port ${PORTS} \
# --timeout ${TIMEOUT} \
# --threads ${THREADS}
}
function list(){
@ -33,20 +35,30 @@ function list(){
function collect() {
# ./magellan collect --user admin --pass password
${EXE} collect \
--user ${USER} \
--pass ${PASS} \
--timeout ${TIMEOUT} \
--threads ${THREADS} \
--host ${SMD_HOST} \
--port ${SMD_PORT} \
--force-update ${FORCE_UPDATE}
${EXE} collect ${COLLECT_PARAMS}
# --user ${USER} \
# --pass ${PASS} \
# --timeout ${TIMEOUT} \
# --threads ${THREADS} \
# --host ${SMD_HOST} \
# --port ${SMD_PORT} \
# --force-update ${FORCE_UPDATE}
}
# parse incoming arguments to set variables
while [[ $# -gt 0 ]]; do
case $1 in
--scan)
SCAN_PARAMS="$2"
shift
shift
;;
--collect)
COLLECT_PARAMS="$2"
shift
shift
;;
--subnet)
SUBNETS="$2"
shift # past argument
@ -100,15 +112,6 @@ done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
echo "SMD host = ${SMD_HOST}"
echo "SMD port = ${SMD_PORT}"
echo "subnets = ${SUBNETS}"
echo "ports = ${PORTS}"
echo "user = ${USER}"
echo "threads = ${THREADS}"
echo "timeout = ${TIMEOUT}"
echo "pass = ..."
if [[ -n $1 ]]; then
echo "Last line of file specified as non-opt/last argument:"
tail -1 "$1"
@ -116,3 +119,8 @@ fi
scan
collect
# run with docker
# docker run magellan:latest magellan.sh \
# --scan "--subnet 127.16.0.0 --port 443" \
# --collect "--user admin --pass password --timeout 300 --threads 1 --smd-host host --smd-port port"