From ca686dd582570c7d8e00871ca625e593fc357df5 Mon Sep 17 00:00:00 2001 From: Chai Feng Date: Fri, 5 Oct 2018 18:11:33 +0800 Subject: [PATCH] Infinite loop --- docker-entrypoint.sh | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 284fb34..823b545 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -49,24 +49,9 @@ function main() { case "$1" in start) update-ufw-rules - docker events --format '{{.Time}} {{.Status}} {{.Actor.Attributes.name}}' --filter 'scope=local' --filter 'type=container' | - while read time status name; do - echo "$time $status $name" >&2 - [[ -z "$name" ]] && continue - - [[ "$status" = @(kill|start) ]] || continue - - declare -n env_name="ufw_public_$(get-service-id-of "$name")" - [[ -z "${env_name:-}" ]] && continue - - declare port="${env_name:-deny}" - if [[ "$status" = kill ]]; then - port=deny - fi - - echo ufw-update-rule-for-instance "$name" "$port" - done - sleep 60; exit 1 + while true; do + sleep "$(( 3600 * 24 * 7 ))" || break + done ;; delete|allow|add-service-rule) ufw-docker "$@"