extract main function
This commit is contained in:
parent
b1aec55699
commit
e92bdff8c3
@ -55,6 +55,7 @@ function get-service-id-of() {
|
|||||||
docker inspect "$1" --format '{{range $k,$v:=.Config.Labels}}{{ if eq $k "com.docker.swarm.service.id" }}{{$v}}{{end}}{{end}}' | grep -E "^.+\$"
|
docker inspect "$1" --format '{{range $k,$v:=.Config.Labels}}{{ if eq $k "com.docker.swarm.service.id" }}{{$v}}{{end}}{{end}}' | grep -E "^.+\$"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
update-ufw-rules
|
update-ufw-rules
|
||||||
@ -68,12 +69,12 @@ case "$1" in
|
|||||||
declare -n env_name="ufw_public_$(get-service-id-of "$name")"
|
declare -n env_name="ufw_public_$(get-service-id-of "$name")"
|
||||||
[[ -z "${env_name:-}" ]] && continue
|
[[ -z "${env_name:-}" ]] && continue
|
||||||
|
|
||||||
port="${env_name:-deny}"
|
declare port="${env_name:-deny}"
|
||||||
if [[ "$status" = kill ]]; then
|
if [[ "$status" = kill ]]; then
|
||||||
port=deny
|
port=deny
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ufw-update-rule-for-instance "$name" "$port"
|
echo ufw-update-rule-for-instance "$name" "$port"
|
||||||
done
|
done
|
||||||
sleep 60; exit 1
|
sleep 60; exit 1
|
||||||
;;
|
;;
|
||||||
@ -91,3 +92,6 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user