<commit_before>#!/bin/bash
#
# Upload geowave-accumulo.jar into HDFS
#

HDFS_USER=hdfs
ACCUMULO_USER=accumulo
GEOWAVE_ACCUMULO_HOME=/usr/local/geowave/accumulo
ACCUMULO_LIB_DIR=/accumulo/classpath/geowave

REQUIRED_APPS=('hadoop')

# Test for installed apps required to run this script
dependency_tests() {
    for app in "${REQUIRED_APPS[@]}"
    do
        type $app >/dev/null 2>&1 || { echo >&2 "$0 needs the $app command to be installed . Aborting."; exit 1; } 
    done
}

# Sanity check
dependency_tests

# Test to see if Accumulo has been initialized by looking at hdfs contents
su $HDFS_USER -c "hadoop fs -ls /accumulo"
if [ $? -ne 0 ]; then
    echo >&2 "/accumulo directory not found in hdfs. Aborting."; exit 1;
fi

# Check to see if lib directory is already present
su $HDFS_USER -c "hadoop fs -ls $ACCUMULO_LIB_DIR"
if [ $? -ne 0 ]; then # Try creating
    sudo -u $HDFS_USER hadoop fs -mkdir -p $ACCUMULO_LIB_DIR
    if [ $? -ne 0 ]; then
        echo >&2 "Unable to create $ACCUMULO_LIB_DIR directory in hdfs. Aborting."; exit 1;
    fi
fi

# Check to see if the library is already present and remove if so (put will not replace)
su $HDFS_USER -c "hadoop fs -ls $ACCUMULO_LIB_DIR/geowave-accumulo.jar"
if [ $? -eq 0 ]; then
    su $HDFS_USER -c "hadoop fs -rm $ACCUMULO_LIB_DIR/geowave-accumulo.jar"
fi

# Upload library to hdfs
su $HDFS_USER -c "hadoop fs -put $GEOWAVE_ACCUMULO_HOME/geowave-accumulo.jar $ACCUMULO_LIB_DIR/geowave-accumulo.jar"
if [ $? -ne 0 ]; then
    echo >&2 "Unable to upload geowave-accumulo.jar into hdfs. Aborting."; exit 1;
fi

# Set ownership to Accumulo user
su $HDFS_USER -c "hadoop fs -chown -R $ACCUMULO_USER $ACCUMULO_LIB_DIR"
if [ $? -ne 0 ]; then
    echo >&2 "Unable to change ownership of the $ACCUMULO_LIB_DIR directory in hdfs. Aborting."; exit 1;
fi<commit_msg>Use su instead of sudo to avoid problems on systems with requiretty set in sudoers<commit_after>#!/bin/bash
#
# Upload geowave-accumulo.jar into HDFS
#

HDFS_USER=hdfs
ACCUMULO_USER=accumulo
GEOWAVE_ACCUMULO_HOME=/usr/local/geowave/accumulo
ACCUMULO_LIB_DIR=/accumulo/classpath/geowave

REQUIRED_APPS=('hadoop')

# Test for installed apps required to run this script
dependency_tests() {
    for app in "${REQUIRED_APPS[@]}"
    do
        type $app >/dev/null 2>&1 || { echo >&2 "$0 needs the $app command to be installed . Aborting."; exit 1; } 
    done
}

# Sanity check
dependency_tests

# Test to see if Accumulo has been initialized by looking at hdfs contents
su $HDFS_USER -c "hadoop fs -ls /accumulo"
if [ $? -ne 0 ]; then
    echo >&2 "/accumulo directory not found in hdfs. Aborting."; exit 1;
fi

# Check to see if lib directory is already present
su $HDFS_USER -c "hadoop fs -ls $ACCUMULO_LIB_DIR"
if [ $? -ne 0 ]; then # Try creating
    su $HDFS_USER -c "hadoop fs -mkdir -p $ACCUMULO_LIB_DIR"
    if [ $? -ne 0 ]; then
        echo >&2 "Unable to create $ACCUMULO_LIB_DIR directory in hdfs. Aborting."; exit 1;
    fi
fi

# Check to see if the library is already present and remove if so (put will not replace)
su $HDFS_USER -c "hadoop fs -ls $ACCUMULO_LIB_DIR/geowave-accumulo.jar"
if [ $? -eq 0 ]; then
    su $HDFS_USER -c "hadoop fs -rm $ACCUMULO_LIB_DIR/geowave-accumulo.jar"
fi

# Upload library to hdfs
su $HDFS_USER -c "hadoop fs -put $GEOWAVE_ACCUMULO_HOME/geowave-accumulo.jar $ACCUMULO_LIB_DIR/geowave-accumulo.jar"
if [ $? -ne 0 ]; then
    echo >&2 "Unable to upload geowave-accumulo.jar into hdfs. Aborting."; exit 1;
fi

# Set ownership to Accumulo user
su $HDFS_USER -c "hadoop fs -chown -R $ACCUMULO_USER $ACCUMULO_LIB_DIR"
if [ $? -ne 0 ]; then
    echo >&2 "Unable to change ownership of the $ACCUMULO_LIB_DIR directory in hdfs. Aborting."; exit 1;
fi
{'fraction_non_alphanumeric': 0.10796221322537113, 'fraction_numerical': 0.010256410256410256, 'mean_word_length': 3.673392181588903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7555179', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1381, 'n_words': 469}