<commit_before>#!/bin/bash

function warn {
 echo `date` $@
}

function usage {
    echo "Usage: glidein_startup.sh <options>"
    echo "where <options> is:"
    echo "  -factory <name>       : name of this factory"
    echo "  -name <name>          : name of this glidein"
    echo "  -entry <name>         : name of this glidein entry"
    echo "  -web <baseURL>        : base URL from where to fetch"
    echo "  -proxy <proxyURL>     : URL of the local proxy"
    echo "  -dir <dirID>          : directory ID (supports ., Condor, CONDOR, OSG, TMPDIR)"
    echo "  -sign <sign>          : signature of the signature file"
    echo "  -signtype <id>        : type of signature (only sha1 supported for now)"
    echo "  -signentry <sign>     : signature of the entry signature file"
    echo "  -cluster <ClusterID>  : condorG ClusterId"
    echo "  -subcluster <ProcID>  : condorG ProcId"
    echo "  -schedd <name>        : condorG Schedd Name"
    echo "  -descript <fname>     : description file name"
    echo "  -descriptentry <fname>: description file name for entry"
    echo "  -v <id>               : verbosity level (std and dbg supported)"
    echo "  -param_* <arg>        : user specified parameters"
    exit 1
}


# params will contain the full list of parameters
# -param_XXX YYY will become "XXX YYY"
params=""

while [ $# -gt 0 ]
do case "$1" in
    -factory)    glidein_factory="$2";;
    -name)       glidein_name="$2";;
    -entry)      glidein_entry="$2";;
    -web)        repository_url="$2";;
    -proxy)      proxy_url="$2";;
    -dir)        work_dir="$2";;
    -sign)       sign_id="$2";;
    -signtype)   sign_type="$2";;
    -signentry)  sign_entry_id="$2";;
    -cluster)    condorg_cluster="$2";;
    -subcluster) condorg_subcluster="$2";;
    -schedd)     condorg_schedd="$2";;
    -descript)   descript_file="$2";;
    -descriptentry)   descript_entry_file="$2";;
    -v)          debug_mode="$2";;
    -param_*)    params="$params `echo $1 | awk '{print substr($0,8)}'` $2";;
    *)  (warn "Unknown option $1"; usage) 1>&2; exit 1
esac
shift
shift
done

####################################
# Cleaup, print out message and exit
work_dir_created=0
function glidein_exit {
  if [ $1 -ne 0 ]; then
    sleep $sleep_time # wait a bit in case of error, to reduce lost glideins
  fi
  cd "$start_dir"
  if [ "$work_dir_created" -eq "1" ]; then
    rm -fR "$work_dir"
  fi

  glidein_end_time=`date +%s`
  let total_time=$glidein_end_time-$startup_time
  echo "=== Glidein ending `date` ($glidein_end_time) with code $1 after $total_time ==="
 
  exit $1
}

# Create a script that defines add_config_line
# This way other depending scripts can use it
function create_add_config_line {
    cat > "$1" << EOF
###################################
# Add a line to the config file
function add_config_line {
    id=$1

    rm -f ${glidein_config}.old #just in case one was there
    mv $glidein_config ${glidein_config}.old
    if [ $? -ne 0 ]; then
        warn "Error renaming $glidein_config into ${glidein_config}.old"
        exit 1
    fi
    grep -v "^$id " ${glidein_config}.old > $glidein_config
    echo "$@" >> $glidein_config
    rm -f ${glidein_config}.old
}
EOF<commit_msg>Fix bug<commit_after>#!/bin/bash

function warn {
 echo `date` $@
}

function usage {
    echo "Usage: glidein_startup.sh <options>"
    echo "where <options> is:"
    echo "  -factory <name>       : name of this factory"
    echo "  -name <name>          : name of this glidein"
    echo "  -entry <name>         : name of this glidein entry"
    echo "  -web <baseURL>        : base URL from where to fetch"
    echo "  -proxy <proxyURL>     : URL of the local proxy"
    echo "  -dir <dirID>          : directory ID (supports ., Condor, CONDOR, OSG, TMPDIR)"
    echo "  -sign <sign>          : signature of the signature file"
    echo "  -signtype <id>        : type of signature (only sha1 supported for now)"
    echo "  -signentry <sign>     : signature of the entry signature file"
    echo "  -cluster <ClusterID>  : condorG ClusterId"
    echo "  -subcluster <ProcID>  : condorG ProcId"
    echo "  -schedd <name>        : condorG Schedd Name"
    echo "  -descript <fname>     : description file name"
    echo "  -descriptentry <fname>: description file name for entry"
    echo "  -v <id>               : verbosity level (std and dbg supported)"
    echo "  -param_* <arg>        : user specified parameters"
    exit 1
}


# params will contain the full list of parameters
# -param_XXX YYY will become "XXX YYY"
params=""

while [ $# -gt 0 ]
do case "$1" in
    -factory)    glidein_factory="$2";;
    -name)       glidein_name="$2";;
    -entry)      glidein_entry="$2";;
    -web)        repository_url="$2";;
    -proxy)      proxy_url="$2";;
    -dir)        work_dir="$2";;
    -sign)       sign_id="$2";;
    -signtype)   sign_type="$2";;
    -signentry)  sign_entry_id="$2";;
    -cluster)    condorg_cluster="$2";;
    -subcluster) condorg_subcluster="$2";;
    -schedd)     condorg_schedd="$2";;
    -descript)   descript_file="$2";;
    -descriptentry)   descript_entry_file="$2";;
    -v)          debug_mode="$2";;
    -param_*)    params="$params `echo $1 | awk '{print substr($0,8)}'` $2";;
    *)  (warn "Unknown option $1"; usage) 1>&2; exit 1
esac
shift
shift
done

####################################
# Cleaup, print out message and exit
work_dir_created=0
function glidein_exit {
  if [ $1 -ne 0 ]; then
    sleep $sleep_time # wait a bit in case of error, to reduce lost glideins
  fi
  cd "$start_dir"
  if [ "$work_dir_created" -eq "1" ]; then
    rm -fR "$work_dir"
  fi

  glidein_end_time=`date +%s`
  let total_time=$glidein_end_time-$startup_time
  echo "=== Glidein ending `date` ($glidein_end_time) with code $1 after $total_time ==="
 
  exit $1
}

# Create a script that defines add_config_line
# This way other depending scripts can use it
function create_add_config_line {
    cat > "$1" << EOF
###################################
# Add a line to the config file
function add_config_line {
    id=\$1

    rm -f \${glidein_config}.old #just in case one was there
    mv \$glidein_config \${glidein_config}.old
    if [ \$? -ne 0 ]; then
        warn "Error renaming \$glidein_config into \${glidein_config}.old"
        exit 1
    fi
    grep -v "^\$id " \${glidein_config}.old > \$glidein_config
    echo "\$@" >> \$glidein_config
    rm -f \${glidein_config}.old
}
EOF
{'fraction_non_alphanumeric': 0.15409734100450942, 'fraction_numerical': 0.011506764111335718, 'mean_word_length': 2.6859598853868194, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 49, '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': '1670509', 'n_tokens_mistral': 2254, 'n_tokens_neox': 2193, 'n_words': 662}