<commit_before>#!/bin/bash
# -*- mode: shell-script; fill-column: 80; -*-
#
# Copyright (c) 2013 Joyent Inc., All rights reserved.
#

export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace

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

export PATH=$SVC_ROOT/build/node/bin:/opt/local/bin:/usr/sbin/:/usr/bin:$PATH

# Install zookeeper package, need to touch this file to disable the license prompt
touch /opt/local/.dli_license_accepted

function manta_setup_zookeeper {
    manta_add_logadm_entry "zookeeper" "/var/log"

    svccfg import /opt/local/share/smf/zookeeper-server/manifest.xml || \
        fatal "unable to import ZooKeeper"
    svcadm enable zookeeper || fatal "unable to start ZooKeeper"
}

#
# XXX in the future this should come from SAPI and we should be pulling out
# the "application" that's the parent of this instance. (see: SAPI-173)
#
if [[ -n $(mdata-get sdc:tags.manta_role) ]]; then
    export FLAVOR="manta"
else
    export FLAVOR="sdc"
fi

if [[ ${FLAVOR} == "manta" ]]; then
    source ${DIR}/scripts/util.sh
    source ${DIR}/scripts/services.sh

    export ZOO_LOG4J_PROP=TRACE,CONSOLE

    echo "Running common setup scripts"
    manta_common_presetup

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

    manta_common_setup "binder"

    echo "Setting up ZooKeeper"
    manta_setup_zookeeper

    manta_ensure_zk

    echo "Installing binder"
    svccfg import $SVC_ROOT/smf/manifests/binder.xml || \
        fatal "unable to import binder"
    svcadm enable binder || fatal "unable to start binder"

    manta_common_setup_end

else # FLAVOR == "sdc"

    # Include common utility functions (then run the boilerplate)
    source /opt/smartdc/boot/lib/util.sh
    CONFIG_AGENT_LOCAL_MANIFESTS_DIRS=/opt/smartdc/binder
    sdc_common_setup

    # Cookie to identify this as a SmartDC zone and its role
    mkdir -p /var/smartdc/binder
    mkdir -p /opt/smartdc/etc

    echo "Importing zookeeper SMF manifest."
    [[ -z $(/usr/bin/svcs -a | grep zookeeper) ]] && \
      /usr/sbin/svccfg import /opt/local/share/smf/zookeeper-server/manifest.xml

    echo "Importing binder SMF manifest."
    [[ -z $(/usr/bin/svcs -a | grep binder) ]] && \
      /usr/sbin/svccfg import /opt/smartdc/binder/smf/manifests/binder.xml

    # Log rotation.
    sdc_log_rotation_add amon-agent /var/svc/log/*amon-agent*.log 1g
    sdc_log_rotation_add config-agent /var/svc/log/*config-agent*.log 1g
    sdc_log_rotation_add registrar /var/svc/log/*registrar*.log 1g
    sdc_log_rotation_add binder /var/svc/log/*binder*.log 1g
    sdc_log_rotation_setup_end<commit_msg>HEAD-1365 rotate zookeeper log as well<commit_after>#!/bin/bash
# -*- mode: shell-script; fill-column: 80; -*-
#
# Copyright (c) 2013 Joyent Inc., All rights reserved.
#

export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace

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

export PATH=$SVC_ROOT/build/node/bin:/opt/local/bin:/usr/sbin/:/usr/bin:$PATH

# Install zookeeper package, need to touch this file to disable the license prompt
touch /opt/local/.dli_license_accepted

function manta_setup_zookeeper {
    manta_add_logadm_entry "zookeeper" "/var/log"

    svccfg import /opt/local/share/smf/zookeeper-server/manifest.xml || \
        fatal "unable to import ZooKeeper"
    svcadm enable zookeeper || fatal "unable to start ZooKeeper"
}

#
# XXX in the future this should come from SAPI and we should be pulling out
# the "application" that's the parent of this instance. (see: SAPI-173)
#
if [[ -n $(mdata-get sdc:tags.manta_role) ]]; then
    export FLAVOR="manta"
else
    export FLAVOR="sdc"
fi

if [[ ${FLAVOR} == "manta" ]]; then
    source ${DIR}/scripts/util.sh
    source ${DIR}/scripts/services.sh

    export ZOO_LOG4J_PROP=TRACE,CONSOLE

    echo "Running common setup scripts"
    manta_common_presetup

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

    manta_common_setup "binder"

    echo "Setting up ZooKeeper"
    manta_setup_zookeeper

    manta_ensure_zk

    echo "Installing binder"
    svccfg import $SVC_ROOT/smf/manifests/binder.xml || \
        fatal "unable to import binder"
    svcadm enable binder || fatal "unable to start binder"

    manta_common_setup_end

else # FLAVOR == "sdc"

    # Include common utility functions (then run the boilerplate)
    source /opt/smartdc/boot/lib/util.sh
    CONFIG_AGENT_LOCAL_MANIFESTS_DIRS=/opt/smartdc/binder
    sdc_common_setup

    # Cookie to identify this as a SmartDC zone and its role
    mkdir -p /var/smartdc/binder
    mkdir -p /opt/smartdc/etc

    echo "Importing zookeeper SMF manifest."
    [[ -z $(/usr/bin/svcs -a | grep zookeeper) ]] && \
      /usr/sbin/svccfg import /opt/local/share/smf/zookeeper-server/manifest.xml

    echo "Importing binder SMF manifest."
    [[ -z $(/usr/bin/svcs -a | grep binder) ]] && \
      /usr/sbin/svccfg import /opt/smartdc/binder/smf/manifests/binder.xml

    # Log rotation.
    sdc_log_rotation_add amon-agent /var/svc/log/*amon-agent*.log 1g
    sdc_log_rotation_add config-agent /var/svc/log/*config-agent*.log 1g
    sdc_log_rotation_add registrar /var/svc/log/*registrar*.log 1g
    sdc_log_rotation_add binder /var/svc/log/*binder*.log 1g
    sdc_log_rotation_add zookeeper /var/log/zookeeper/zookeeper.out 1g
    sdc_log_rotation_setup_end
{'fraction_non_alphanumeric': 0.1278538812785388, 'fraction_numerical': 0.007200561995082543, 'mean_word_length': 3.4984202211690363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '3458257', 'n_tokens_mistral': 2188, 'n_tokens_neox': 2037, 'n_words': 482}