<commit_before>#!/bin/bash

VERSION=$1

solrversion="solr-$VERSION"
solr_home="/opt/$solrversion"
changed=0

usage() {
    rv=$1
    echo "install_solr.sh <version>"
    exit $rv
}

err_exit() {
    msg=$1
    >&2 echo $msg
    exit 1
}

solr_home_absent() {
    test -d /opt/solr-$VERSION && return 1
    return 0
}

ensure_solr_home_exists() {
    if solr_home_absent; then
        mkdir /opt/solr-$VERSION || exit 1
    fi
}

link_logging_jars() {
    jarpat="log4j-*.jar slf4j-api-*.jar jcl-over-slf4j-*.jar"
    jars=`cd $solr_home/dpla/lib/ext; ls $jarpat`
    for jar in $jars; do
        ln -sf $solr_home/dpla/lib/ext/$jar /usr/share/tomcat7/lib/$jar \
            || err_exit "Could not symlink $jar"
    done
}

test -z "$VERSION" && usage 1

if solr_home_absent; then
    tarfile_name="$solrversion.tgz"
    dl_base="http://archive.apache.org/dist/lucene/solr/$VERSION"
    dl_url="$dl_base/$tarfile_name"
    cd /var/tmp
    wget -q $dl_url || err_exit "Could not get $dl_url"
    tar -zxf $tarfile_name || err_exit "Could not extract $tarfile_name"
    ensure_solr_home_exists
    mkdir $solr_home/bin || exit 1
    mkdir $solr_home/lib || exit 1
    mkdir $solr_home/dpla || exit 1
    rsync -a $solrversion/example/ $solr_home/dpla || exit 1
    cp -p $solrversion/dist/$solrversion.war $solr_home/solr.war || exit 1
    link_logging_jars
    cp /var/tmp/$solrversion/contrib/analysis-extras/lucene-libs/*.jar \
        $solr_home/lib || exit 1
    cp /var/tmp/$solrversion/contrib/analysis-extras/lib/*.jar \
        $solr_home/lib || exit 1
    cp /var/tmp/$solrversion/dist/solr-analysis-extras*.jar \
        $solr_home/lib || exit 1
    # The data directory is symlinked to keep Solr happy when it first starts.
    # We'll define it explicitly in solrconfig.xml when that gets copied later.
    ln -sf /v1/solrdata $solr_home/dpla/solr/collection1/data
    rm -rf /var/tmp/solr-$VERSION*
    cd /opt
    ln -sf $solrversion solr || err_exit "Could not symlink solr directory"
    changed=1
fi

if [ $changed -eq 1 ]; then echo "changed"; fi

exit 0
<commit_msg>Add symlink to fix Solr startup error<commit_after>#!/bin/bash

VERSION=$1

solrversion="solr-$VERSION"
solr_home="/opt/$solrversion"
changed=0

usage() {
    rv=$1
    echo "install_solr.sh <version>"
    exit $rv
}

err_exit() {
    msg=$1
    >&2 echo $msg
    exit 1
}

solr_home_absent() {
    test -d /opt/solr-$VERSION && return 1
    return 0
}

ensure_solr_home_exists() {
    if solr_home_absent; then
        mkdir /opt/solr-$VERSION || exit 1
    fi
}

link_logging_jars() {
    jarpat="log4j-*.jar slf4j-api-*.jar jcl-over-slf4j-*.jar"
    jars=`cd $solr_home/dpla/lib/ext; ls $jarpat`
    for jar in $jars; do
        ln -sf $solr_home/dpla/lib/ext/$jar /usr/share/tomcat7/lib/$jar \
            || err_exit "Could not symlink $jar"
    done
}

test -z "$VERSION" && usage 1

if solr_home_absent; then
    tarfile_name="$solrversion.tgz"
    dl_base="http://archive.apache.org/dist/lucene/solr/$VERSION"
    dl_url="$dl_base/$tarfile_name"
    cd /var/tmp
    wget -q $dl_url || err_exit "Could not get $dl_url"
    tar -zxf $tarfile_name || err_exit "Could not extract $tarfile_name"
    ensure_solr_home_exists
    mkdir $solr_home/bin || exit 1
    mkdir $solr_home/lib || exit 1
    mkdir $solr_home/dpla || exit 1
    rsync -a $solrversion/example/ $solr_home/dpla || exit 1
    cp -p $solrversion/dist/$solrversion.war $solr_home/solr.war || exit 1
    link_logging_jars
    cp /var/tmp/$solrversion/contrib/analysis-extras/lucene-libs/*.jar \
        $solr_home/lib || exit 1
    cp /var/tmp/$solrversion/contrib/analysis-extras/lib/*.jar \
        $solr_home/lib || exit 1
    cp /var/tmp/$solrversion/dist/solr-analysis-extras*.jar \
        $solr_home/lib || exit 1
    # The data directory is symlinked to keep Solr happy when it first starts.
    # We'll define it explicitly in solrconfig.xml when that gets copied later.
    ln -sf /v1/solrdata $solr_home/dpla/solr/collection1/data
    rm -rf /var/tmp/solr-$VERSION*
    cd /opt
    ln -sf $solrversion solr || err_exit "Could not symlink solr directory"
    ln -sf /opt/solr/dpla/solr /var/lib/tomcat7/solr \
        || err_exit "Could not symlink solr into /var/lib/tomcat7"
    changed=1
fi

if [ $changed -eq 1 ]; then echo "changed"; fi

exit 0

{'fraction_non_alphanumeric': 0.13195732838589982, 'fraction_numerical': 0.012987012987012988, 'mean_word_length': 2.8134394341290894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5311650', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1668, 'n_words': 385}