From a21bac599ed8bf57070591d241db00ec1e6e7b33 Mon Sep 17 00:00:00 2001 From: gsd Date: Tue, 15 Oct 2024 12:09:23 +0300 Subject: [PATCH] sh script to check --- docker-compose.yaml | 1 + upcheck.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100755 upcheck.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 132da84..c1f56af 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -36,6 +36,7 @@ services: restart: unless-stopped proxywg_client: + container_name: proxywg_client image: wireguard:clear cap_add: - NET_ADMIN diff --git a/upcheck.sh b/upcheck.sh new file mode 100755 index 0000000..a80f236 --- /dev/null +++ b/upcheck.sh @@ -0,0 +1,22 @@ +#!/bin/bash +cd "$(dirname "$0")" + +CONTAINER=proxywg_socks_c +PINGHOST=8.8.8.8 + +CHECK_CONTAINER="$(docker ps | grep $CONTAINER | wc -l)" +if [ "$CHECK_CONTAINER" == "0" ]; then + echo 'container is not started' + docker compose up -d + exit 0 +fi + +RESULT="$(docker exec -it $CONTAINER ping -c 1 -W 1 $PINGHOST > /dev/null && echo 'pass' || echo 'fail')" +#echo $RESULT + +if [ "$RESULT" != "pass" ]; then + echo 'container is not good' + docker compose down + docker compose up -d + exit 0 +fi