<commit_before>#!/bin/bash

# exit on any error
set -e

echo "Welcome to configuressl.sh"
echo "Number of parameters was: " $#

if [ $# -ne 3 ]; then
    echo usage: $0 {git private key} {git reponame} {git user id}      
	exit 1
fi

gitSshPrivateKey=$1
gitRepoName=$2
gitUserId=$3

configure_git_cron()
{
    echo "configurng cron for code updates from git"
    #Configure cronjob to perform git pull every 10 minutes
    echo '*/10 * * * * echo $(date) >> /var/log/cronjob.log && cd /var/www && git pull >> /var/log/cronjob.log 2>&1' >> /tmp/tmp_gitcron
    echo "configurng cron for cache invalidtion"

    echo 'Writing to crontab'
    crontab /tmp/tmp_gitcron
    rm /tmp/tmp_gitcron 
}

setup_sshkey()
{
    local key=${1}
    local host=${2}
    local user=${3}

    key=$(echo $key | base64 --decode);

    local keyfile=~/.ssh/${host}.key

echo "Creating ssh key file.."
cat > "/tmp/tmp_key" << EOF
$key
EOF

cat >> ~/.ssh/config << EOF
Host $host
    HostName $host
    User $user
    IdentityFile $keyfile
EOF

    # Generate the final ssh private key from the keyvault and place in root user context
    cp /tmp/tmp_key $keyfile

    # Add the git domain to known_hosts file for root
    ssh-keyscan $host >> ~/.ssh/known_hosts

    chmod 400 $keyfile

    #remove the tmp key in /tmp/tmp_key
    rm /tmp/tmp_key
}

configure_git()
{
    local key=${1}
    local host=${2}
    local user=${3}
    local repo=${4}

    echo "Configuring git connectivity for $repo"
    echo "Registering git domain: $host"

    if [ ! -z "$key" ]; then
        setup_sshkey $key $host $user

        # remove html dir so we can clone into it
        rm -rf /var/www/html
<commit_msg>more formatting<commit_after>#!/bin/bash

# exit on any error
set -e

echo "Welcome to configuressl.sh"
echo "Number of parameters was: " $#

if [ $# -ne 3 ]; then
    echo usage: $0 {git private key} {git reponame} {git user id}      
	exit 1
fi

gitSshPrivateKey=$1
gitRepoName=$2
gitUserId=$3

configure_git_cron()
{
    echo "configurng cron for code updates from git"
    #Configure cronjob to perform git pull every 10 minutes
    echo '*/10 * * * * echo $(date) >> /var/log/cronjob.log && cd /var/www && git pull >> /var/log/cronjob.log 2>&1' >> /tmp/tmp_gitcron
    echo "configurng cron for cache invalidtion"

    echo 'Writing to crontab'
    crontab /tmp/tmp_gitcron
    rm /tmp/tmp_gitcron 
}

setup_sshkey()
{
    local key=${1}
    local host=${2}
    local user=${3}

    key=$(echo $key | base64 --decode);

    local keyfile=~/.ssh/${host}.key

echo "Creating ssh key file.."
cat > "/tmp/tmp_key" << EOF
$key
EOF

cat >> ~/.ssh/config << EOF
Host $host
HostName $host
User $user
IdentityFile $keyfile
EOF

    # Generate the final ssh private key from the keyvault and place in root user context
    cp /tmp/tmp_key $keyfile

    # Add the git domain to known_hosts file for root
    ssh-keyscan $host >> ~/.ssh/known_hosts

    chmod 400 $keyfile

    #remove the tmp key in /tmp/tmp_key
    rm /tmp/tmp_key
}

configure_git()
{
    local key=${1}
    local host=${2}
    local user=${3}
    local repo=${4}

    echo "Configuring git connectivity for $repo"
    echo "Registering git domain: $host"

    if [ ! -z "$key" ]; then
        setup_sshkey $key $host $user

        # remove html dir so we can clone into it
        rm -rf /var/www/html

{'fraction_non_alphanumeric': 0.12320574162679426, 'fraction_numerical': 0.014354066985645933, 'mean_word_length': 2.758426966292135, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7476120', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1160, 'n_words': 395}