From f9362d9286a4aa1173b191c0e652644fd9c8e5f8 Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Fri, 25 Jul 2025 14:51:23 +0200 Subject: [PATCH] =?utf8?q?Dodanie=20pliku=20vpn-check.sh=20-=20skrypt=20sp?= =?utf8?q?rawdza=20dost=C4=99pno=C5=9B=C4=87=20host=C3=B3w=20w=20sieci=20V?= =?utf8?q?PN.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- vpn-check.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 vpn-check.sh diff --git a/vpn-check.sh b/vpn-check.sh new file mode 100755 index 0000000..cc1dcd9 --- /dev/null +++ b/vpn-check.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +BOLD="\e[1m"; +RED="\e[31m"; +GREEN="\e[32m"; +ENDCOLOR="\e[0m"; + +function PING_COMMAND() { ping -c 1 -w 1 $1 > /dev/null 2>&1; } + +FILENAME="/etc/openvpn/ipp.txt"; + +i=1; +nOL=$(wc -l $FILENAME | awk '{printf $1}'); + +while [ $i -le $nOL ]; do + hostname=$(sed -n "${i}p" $FILENAME | cut -d "," -f 1); + IP=$(sed -n "${i}p" $FILENAME | cut -d "," -f 2); + if $(PING_COMMAND $IP); then + echo -e "[${BOLD}${GREEN}*${ENDCOLOR}] $hostname"; + else + echo -e "[${BOLD}${RED}*${ENDCOLOR}] $hostname"; + fi + i=$(expr $i + 1); +done -- 2.39.5