mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Merge pull request #9 from davidallendj/update-docker
Update Dockerfile and `magellan.sh` script to run in container
This commit is contained in:
commit
4298912ee7
2 changed files with 96 additions and 11 deletions
|
|
@ -1,13 +1,15 @@
|
||||||
FROM cgr.dev/chainguard/wolfi-base
|
FROM cgr.dev/chainguard/wolfi-base
|
||||||
|
|
||||||
RUN apk add --no-cache tini
|
RUN apk add --no-cache tini bash
|
||||||
|
|
||||||
# nobody 65534:65534
|
# nobody 65534:65534
|
||||||
USER 65534:65534
|
USER 65534:65534
|
||||||
|
|
||||||
|
|
||||||
COPY magellan /
|
COPY magellan /magellan
|
||||||
|
COPY bin/magellan.sh /usr/bin/magellan.sh
|
||||||
|
|
||||||
CMD [ "/magellan" ]
|
|
||||||
|
CMD [ "/magellan.sh" ]
|
||||||
|
|
||||||
ENTRYPOINT [ "/sbin/tini", "--" ]
|
ENTRYPOINT [ "/sbin/tini", "--" ]
|
||||||
|
|
|
||||||
97
bin/magellan.sh
Normal file → Executable file
97
bin/magellan.sh
Normal file → Executable file
|
|
@ -1,21 +1,104 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
EXE=./magellan
|
||||||
|
SUBNETS=""
|
||||||
|
PORTS=""
|
||||||
|
USER=""
|
||||||
|
PASS=""
|
||||||
|
SMD_HOST=""
|
||||||
|
SMD_PORT=""
|
||||||
|
THREADS="-1"
|
||||||
|
TIMEOUT="30"
|
||||||
|
ARGS=""
|
||||||
|
|
||||||
|
|
||||||
function build(){
|
function build(){
|
||||||
go mod tidy && go build -C bin/magellan
|
go mod tidy && go build -C bin/magellan
|
||||||
}
|
}
|
||||||
|
|
||||||
function scan() {
|
function scan() {
|
||||||
./magellan scan --subnet 172.16.0.0 --port 443
|
# ./magellan scan --subnet 172.16.0.0 --port 443
|
||||||
|
${EXE} scan --subnet ${SUBNETS} --port ${PORTS} --timeout ${TIMEOUT} --threads ${THREADS}
|
||||||
}
|
}
|
||||||
|
|
||||||
function list(){
|
function list(){
|
||||||
./magellan list
|
# ./magellan list
|
||||||
}
|
${EXE} list
|
||||||
|
|
||||||
function update() {
|
|
||||||
./magellan update --user admin --pass password --host 172.16.0.109 --component BMC --protocol HTTP --firmware-path ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function collect() {
|
function collect() {
|
||||||
./magellan collect --user admin --pass password
|
# ./magellan collect --user admin --pass password
|
||||||
|
${EXE} collect --user ${USER} --pass ${PASS} --timeout ${TIMEOUT} --threads ${THREADS} --host ${SMD_HOST} --port ${SMD_PORT}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# parse incoming arguments to set variables
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--subnet)
|
||||||
|
SUBNETS="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
-p|--port)
|
||||||
|
PORTS="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
--user)
|
||||||
|
USER="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
--pass|--password)
|
||||||
|
PASS="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--smd-host)
|
||||||
|
SMD_HOST="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--smd-port)
|
||||||
|
SMD_PORT="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--timeout)
|
||||||
|
TIMEOUT="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--threads)
|
||||||
|
THREADS="$2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*|--*)
|
||||||
|
echo "Unknown option $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ARGS+=("$1") # save positional arg
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
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 "pass = ..."
|
||||||
|
|
||||||
|
if [[ -n $1 ]]; then
|
||||||
|
echo "Last line of file specified as non-opt/last argument:"
|
||||||
|
tail -1 "$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
scan
|
||||||
|
collect
|
||||||
Loading…
Add table
Add a link
Reference in a new issue