<commit_before>#!/bin/bash


function createTunnel() {
	remoteURL=$1
	remotePort=$2
	localPort=$3
	sshUser=$4
	cmd="ssh -N -R $remoteURL:$remotePort:localhost:$localPort "
	
	if [[ ! -z "$4" ]];
	then
		cmd="$cmd $sshUser@"
	fi
	cmd="$cmd$remoteURL" 
	echo $cmd
	eval "$cmd"
	if [[ $? -eq 0 ]]; then
		echo Tunnel to jumpbox created successfully
	else
		echo An error occurred creating a tunnel. RC was $?
	fi
}

#if [[ $(ps aux | grep "$cmd" | grep -v "grep" | wc -l) -eq "0" ]]; then
#  echo Creating new tunnel connection
#  createTunnel
#fi

if [ "${1}" == "create" ]; then
	if [[ ! -e  "config/config.sh" ]]; then
		mkdir config
		cp config_example.sh config/config.sh
		echo Please configure 'config/config.sh'
		exit 1
	fi
	. config/config.sh
	createTunnel REMOTE_URL REMOTE_PORT LOCAL_PORT REMOTE_USER
fi
<commit_msg>added check to see if connection is running<commit_after>#!/bin/bash

function isCMDRunning(){
	$(ps aux | grep "$1" | grep -v "grep" | wc -l) -eg "0"
}

function createTunnel() {
	remoteURL=$1
	remotePort=$2
	localPort=$3
	sshUser=$4
	cmd="ssh -N -R $remoteURL:$remotePort:localhost:$localPort "
	
	if [[ ! -z "$4" ]];
	then
		cmd="$cmd $sshUser@"
	fi
	cmd="$cmd$remoteURL" 
	if [[ $( isCMDRunning "$cmd" ) -ne "0" ]]; then
		exit 2
	fi

	eval "$cmd"
	if [[ $? -eq 0 ]]; then
		echo Tunnel to jumpbox created successfully
	else
		echo An error occurred creating a tunnel. RC was $?
	fi
}

#if [[ $(ps aux | grep "$cmd" | grep -v "grep" | wc -l) -eq "0" ]]; then
#  echo Creating new tunnel connection
#  createTunnel
#fi

if [ "${1}" == "create" ]; then
	if [[ ! -e  "config/config.sh" ]]; then
		mkdir config
		cp config_example.sh config/config.sh
		echo Please configure 'config/config.sh'
		exit 1
	fi
	. config/config.sh
	createTunnel REMOTE_URL REMOTE_PORT LOCAL_PORT REMOTE_USER
fi

{'fraction_non_alphanumeric': 0.15482093663911844, 'fraction_numerical': 0.012121212121212121, 'mean_word_length': 3.5286783042394014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '193135', 'n_tokens_mistral': 750, 'n_tokens_neox': 685, 'n_words': 209}