You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
597 B
32 lines
597 B
#!/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
|
|
|
|
COUNT=0
|
|
MAXPING=30
|
|
|
|
while [ $COUNT -le $MAXPING ]
|
|
do
|
|
COUNT=`expr $COUNT + 1`
|
|
RESULT="$(docker exec -it $CONTAINER ping -c 1 -W 1 $PINGHOST > /dev/null && echo 'pass' || echo 'fail')"
|
|
|
|
if [ "$RESULT" == "pass" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [ $COUNT -ge 29 ]; then
|
|
echo 'container is not good'
|
|
docker compose down
|
|
docker compose up -d
|
|
exit 0
|
|
fi
|
|
done
|
|
|