34 lines
756 B
HCL
34 lines
756 B
HCL
job "port-discovery" {
|
|
datacenters = ["dc1"]
|
|
type = "batch"
|
|
|
|
group "scan" {
|
|
count = 1
|
|
constraint {
|
|
attribute = "${attr.unique.hostname}"
|
|
value = "odroid6"
|
|
}
|
|
|
|
task "scan" {
|
|
driver = "docker"
|
|
config {
|
|
image = "busybox"
|
|
network_mode = "host"
|
|
command = "sh"
|
|
args = ["local/scan.sh"]
|
|
}
|
|
template {
|
|
data = <<EOF
|
|
#!/bin/sh
|
|
TARGET="192.168.4.227"
|
|
for p in 8085 8086 8087; do
|
|
echo "Testing $p..."
|
|
nc -zv -w 3 $TARGET $p 2>&1 | grep -q "refused" && echo "MATCH: $p is AVAILABLE (Refused)"
|
|
nc -zv -w 3 $TARGET $p 2>&1 | grep -q "succeeded" && echo "BUSY: $p is IN USE"
|
|
done
|
|
EOF
|
|
destination = "local/scan.sh"
|
|
}
|
|
}
|
|
}
|
|
} |