Skip to content

Commit

Permalink
Merge pull request #2 from kirill-zak/feature/ud-01
Browse files Browse the repository at this point in the history
Add checking on exist route
  • Loading branch information
kirill-zak authored Apr 4, 2018
2 parents 223100a + ac40609 commit 29088a0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions unblocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SCRIPT_DIR=`pwd`
CONFIG_PATH="$SCRIPT_DIR/settings.conf"
DOMAINS_PATH="$SCRIPT_DIR/domains.conf"

## Check and read configuration file
## Check and read configuration file
if [ ! -f "$CONFIG_PATH" ]; then
echo "Configuration file is not exist!" >&2
exit 1
Expand Down Expand Up @@ -39,8 +39,15 @@ do

for IP in ${DOMAIN_IPS}
do
echo " * Adding route for IP [$IP]"
route add -net "$IP" dev "$TUN"
IP_EXIST="$(ip route get "$IP" | awk 'NR==1{print $3}')"

if [ "$IP_EXIST" == "$TUN" ]; then
echo "Route for IP [$IP] already exist" >&2
else
echo " * Adding route for IP [$IP]" >&2
route add -net "$IP" dev "$TUN"
fi

done

echo "End of process domain [$DOMAIN]" >&2
Expand Down

0 comments on commit 29088a0

Please sign in to comment.