<commit_before>#!/usr/bin/bash
# -*- mode: shell-script; fill-column: 80; -*-

set -o xtrace

SOURCE="${BASH_SOURCE[0]}"
if [[ -h $SOURCE ]]; then
    SOURCE="$(readlink "$SOURCE")"
fi
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
PROFILE=/root/.bashrc
SVC_ROOT=/opt/smartdc/manatee

source ${DIR}/scripts/util.sh
source ${DIR}/scripts/services.sh


export PATH=$SVC_ROOT/build/node/bin:/opt/local/bin:/usr/sbin/:/usr/bin:$PATH
echo "alias mbunyan=\"bunyan -c \"this.component !== 'ZKPlus'\"  -c 'level >= 30'\""
echo "alias manatee_stat=\"/opt/smartdc/manatee/bin/manatee_stat.js -p \`mdata-get nameservers\`\"" >> $PROFILE


function manta_setup_manatee_env {
    mkdir -p /var/log/manatee

    #.bashrc
    echo "export PATH=\$PATH:/opt/smartdc/manatee/lib/tools:/opt/smartdc/manatee/lib/pg_dump/" >>/root/.bashrc
    echo "alias psql='sudo -u postgres psql'" >>/root/.bashrc

    #cron
    local crontab=/tmp/.manta_manatee_cron
    crontab -l > $crontab

    echo "0 * * * * /opt/smartdc/manatee/lib/pg_dump/pg_dump.sh >> /var/log/manatee/pgdump.log 2>&1" >> $crontab
    [[ $? -eq 0 ]] || fatal "Unable to write to $crontab"
    crontab $crontab
    [[ $? -eq 0 ]] || fatal "Unable import crons"

    manta_add_logadm_entry "manatee-sitter"
    manta_add_logadm_entry "manatee-backupserver"
    manta_add_logadm_entry "manatee-snapshotter"
    manta_add_logadm_entry "postgresql" "/var/pg"
    manta_add_logadm_entry "pgdump" "/var/log/manatee"
}


# Mainline

echo "Running common setup scripts"
manta_common_presetup

echo "Adding local manifest directories"
manta_add_manifest_dir "/opt/smartdc/manatee"

manta_common_setup
manta_setup_manatee_env

ZONE_UUID=`zoneadm list -p | cut -d ':' -f2`
DATASET=zones/$ZONE_UUID/data/manatee<commit_msg>MANTA-1613 manatee SDC manifests included by accident<commit_after>#!/usr/bin/bash
# -*- mode: shell-script; fill-column: 80; -*-

set -o xtrace

SOURCE="${BASH_SOURCE[0]}"
if [[ -h $SOURCE ]]; then
    SOURCE="$(readlink "$SOURCE")"
fi
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
PROFILE=/root/.bashrc
SVC_ROOT=/opt/smartdc/manatee

source ${DIR}/scripts/util.sh
source ${DIR}/scripts/services.sh


export PATH=$SVC_ROOT/build/node/bin:/opt/local/bin:/usr/sbin/:/usr/bin:$PATH
echo "alias mbunyan=\"bunyan -c \"this.component !== 'ZKPlus'\"  -c 'level >= 30'\""
echo "alias manatee_stat=\"/opt/smartdc/manatee/bin/manatee_stat.js -p \`mdata-get nameservers\`\"" >> $PROFILE


function manta_setup_manatee_env {
    mkdir -p /var/log/manatee

    #.bashrc
    echo "export PATH=\$PATH:/opt/smartdc/manatee/lib/tools:/opt/smartdc/manatee/lib/pg_dump/" >>/root/.bashrc
    echo "alias psql='sudo -u postgres psql'" >>/root/.bashrc

    #cron
    local crontab=/tmp/.manta_manatee_cron
    crontab -l > $crontab

    echo "0 * * * * /opt/smartdc/manatee/lib/pg_dump/pg_dump.sh >> /var/log/manatee/pgdump.log 2>&1" >> $crontab
    [[ $? -eq 0 ]] || fatal "Unable to write to $crontab"
    crontab $crontab
    [[ $? -eq 0 ]] || fatal "Unable import crons"

    manta_add_logadm_entry "manatee-sitter"
    manta_add_logadm_entry "manatee-backupserver"
    manta_add_logadm_entry "manatee-snapshotter"
    manta_add_logadm_entry "postgresql" "/var/pg"
    manta_add_logadm_entry "pgdump" "/var/log/manatee"
}


# Mainline

# XXX See MANTA-1613.  These manifests are shipped for SDC but aren't relevant
# for the manta image, so remove them until the situation with SDC/manta
# manifests is resolved.
rm -rf $SVC_ROOT/sapi_manifests/registrar
rm -rf $SVC_ROOT/sapi_manifests/sitter

echo "Running common setup scripts"
manta_common_presetup

echo "Adding local manifest directories"
manta_add_manifest_dir "/opt/smartdc/manatee"

manta_common_setup
manta_setup_manatee_env

ZONE_UUID=`zoneadm list -p | cut -d ':' -f2`
DATASET=zones/$ZONE_UUID/data/manatee
{'fraction_non_alphanumeric': 0.15804673142557102, 'fraction_numerical': 0.007876082961407193, 'mean_word_length': 3.9609375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '3900964', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1499, 'n_words': 290}