<commit_before>#!/usr/bin/env bash


# test for root
if [[ "$USER" != "root" ]]; then
    echo "$0 must be executed as root"
    exit;
fi


# get original gateway to make sure it exists afterward
DEFAULT_ROUTE_LINE=$(route -n | grep ^0.0.0.0)

# connect to VPN: must insert login credentials
vpnc-connect --gateway xdata.data-tactics-corp.com --id xdata && \
	route add -net 10.1.93.0 netmask 255.255.255.0 dev tun0 && \
	route add -net 10.1.92.0 netmask 255.255.255.0 dev tun0 && \
	route add -net 10.1.90.0 netmask 255.255.255.0 dev tun0 && \
	route del -net 0.0.0.0 tun0

# make sure original gateway exists
if [[ -z $(route -n | grep ^0.0.0.0) | grep $DEFAULT_IF$ ]]; then
	DEFAULT_GATEWAY=$(awk '{print $2}' <(echo $DEFAULT_ROUTE_LINE))
	DEFAULT_IF=$(awk '{print $NF}' <(echo $DEFAULT_ROUTE_LINE))
	route add -net 0.0.0.0 gw $DEFAULT_GATEWAY dev $DEFAULT_IF
fi

# make sure /etc/resolv.conf works
> /etc/resolv.conf.tmp<commit_msg>BUGFIX: fix typo; also verify that vpn interface exists before proceeding<commit_after>#!/usr/bin/env bash


# test for root
if [[ "$USER" != "root" ]]; then
    echo "$0 must be executed as root"
    exit;
fi


# get original gateway to make sure it exists afterward
DEFAULT_ROUTE_LINE=$(route -n | grep ^0.0.0.0)

# connect to VPN: must insert login credentials
vpnc-connect --gateway xdata.data-tactics-corp.com --id xdata && \
	route add -net 10.1.93.0 netmask 255.255.255.0 dev tun0 && \
	route add -net 10.1.92.0 netmask 255.255.255.0 dev tun0 && \
	route add -net 10.1.90.0 netmask 255.255.255.0 dev tun0 && \
	route del -net 0.0.0.0 tun0

# make sure tun0 exists before proceeding
if [[ -z $(ifconfig | grep tun0) ]]; then
	echo "interface tun0 doesn't exist; assuming vpnc-connect failed"
	exit
fi

# make sure original gateway exists
if [[ -z $(route -n | grep ^0.0.0.0 | grep $DEFAULT_IF$) ]]; then
	DEFAULT_GATEWAY=$(awk '{print $2}' <(echo $DEFAULT_ROUTE_LINE))
	DEFAULT_IF=$(awk '{print $NF}' <(echo $DEFAULT_ROUTE_LINE))
	route add -net 0.0.0.0 gw $DEFAULT_GATEWAY dev $DEFAULT_IF
fi

# make sure /etc/resolv.conf works
> /etc/resolv.conf.tmp
{'fraction_non_alphanumeric': 0.14620162446249402, 'fraction_numerical': 0.06832298136645963, 'mean_word_length': 3.4553191489361703, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 20, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1060900', 'n_tokens_mistral': 871, 'n_tokens_neox': 793, 'n_words': 251}