<commit_before>#!/usr/bin/bash
#
# Copyright (c) 2011 Joyent Inc., All rights reserved.
#

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

role=ufds
PATH=/opt/smartdc/ufds/build/node/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin

# Local manifests
CONFIG_AGENT_LOCAL_MANIFESTS_DIRS=/opt/smartdc/$role

# Include common utility functions (then run the boilerplate)
source /opt/smartdc/sdc-boot/scripts/util.sh
sdc_common_setup

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

# Install UFDS
mkdir -p /opt/smartdc/ufds/ssl
chown -R nobody:nobody /opt/smartdc/ufds

echo "Generating SSL Certificate"
/opt/local/bin/openssl req -x509 -nodes -subj '/CN=*' -newkey rsa:2048 \
    -keyout /opt/smartdc/ufds/ssl/key.pem -out /opt/smartdc/ufds/ssl/cert.pem \
    -days 3650

# Gather metadata needed for setup
UFDS_ADMIN_IP=$(json -f ${METADATA} ufds_admin_ips)
UFDS_LDAP_ROOT_DN=$(json -f ${METADATA} ufds_ldap_root_dn)
UFDS_LDAP_ROOT_PW=$(json -f ${METADATA} ufds_ldap_root_pw)

UFDS_ADMIN_UUID=$(json -f ${METADATA} ufds_admin_uuid)
UFDS_ADMIN_LOGIN=$(json -f ${METADATA} ufds_admin_login)
UFDS_ADMIN_PW=$(json -f ${METADATA} ufds_admin_pw)
UFDS_ADMIN_EMAIL=$(json -f ${METADATA} ufds_admin_email)

DATACENTER_NAME=$(json -f ${METADATA} datacenter_name)
DATACENTER_COMPANY_NAME=$(json -f ${METADATA} datacenter_company_name)
DATACENTER_LOCATION=$(json -f ${METADATA} datacenter_location)

UFDS_ADMIN_KEY_FINGERPRINT=$(json -f ${METADATA} ufds_admin_key_fingerprint)
UFDS_ADMIN_KEY_OPENSSH=$(json -f ${METADATA} ufds_admin_key_openssh)

IS_UPDATE=$(json -f ${METADATA} IS_UPDATE)

/opt/smartdc/bin/configure || fatal "Unable to configure zone."

echo "Adding log rotation"
logadm -w ufds-master -C 48 -s 100m -p 1h \
    /var/svc/log/smartdc-application-ufds-master:default.log
logadm -w ufds-capi -C 48 -s 100m -p 1h \
    /var/svc/log/smartdc-application-ufds-capi:default.log

# Add build/node/bin and node_modules/.bin to PATH
echo "" >>/root/.profile
echo "export PATH=\$PATH:/opt/smartdc/$role/build/node/bin:/opt/smartdc/$role/node_modules/.bin" >>/root/.profile<commit_msg>HEAD-1804 move ufds setup/configure scripts into zone dataset (don't call configure from setup).<commit_after>#!/usr/bin/bash
#
# Copyright (c) 2011 Joyent Inc., All rights reserved.
#

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

role=ufds
PATH=/opt/smartdc/ufds/build/node/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin

# Local manifests
CONFIG_AGENT_LOCAL_MANIFESTS_DIRS=/opt/smartdc/$role

# Include common utility functions (then run the boilerplate)
source /opt/smartdc/sdc-boot/scripts/util.sh
sdc_common_setup

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

# Install UFDS
mkdir -p /opt/smartdc/ufds/ssl
chown -R nobody:nobody /opt/smartdc/ufds

echo "Generating SSL Certificate"
/opt/local/bin/openssl req -x509 -nodes -subj '/CN=*' -newkey rsa:2048 \
    -keyout /opt/smartdc/ufds/ssl/key.pem -out /opt/smartdc/ufds/ssl/cert.pem \
    -days 3650

# Gather metadata needed for setup
UFDS_ADMIN_IP=$(json -f ${METADATA} ufds_admin_ips)
UFDS_LDAP_ROOT_DN=$(json -f ${METADATA} ufds_ldap_root_dn)
UFDS_LDAP_ROOT_PW=$(json -f ${METADATA} ufds_ldap_root_pw)

UFDS_ADMIN_UUID=$(json -f ${METADATA} ufds_admin_uuid)
UFDS_ADMIN_LOGIN=$(json -f ${METADATA} ufds_admin_login)
UFDS_ADMIN_PW=$(json -f ${METADATA} ufds_admin_pw)
UFDS_ADMIN_EMAIL=$(json -f ${METADATA} ufds_admin_email)

DATACENTER_NAME=$(json -f ${METADATA} datacenter_name)
DATACENTER_COMPANY_NAME=$(json -f ${METADATA} datacenter_company_name)
DATACENTER_LOCATION=$(json -f ${METADATA} datacenter_location)

UFDS_ADMIN_KEY_FINGERPRINT=$(json -f ${METADATA} ufds_admin_key_fingerprint)
UFDS_ADMIN_KEY_OPENSSH=$(json -f ${METADATA} ufds_admin_key_openssh)

IS_UPDATE=$(json -f ${METADATA} IS_UPDATE)

echo "Adding log rotation"
logadm -w ufds-master -C 48 -s 100m -p 1h \
    /var/svc/log/smartdc-application-ufds-master:default.log
logadm -w ufds-capi -C 48 -s 100m -p 1h \
    /var/svc/log/smartdc-application-ufds-capi:default.log

# Add build/node/bin and node_modules/.bin to PATH
echo "" >>/root/.profile
echo "export PATH=\$PATH:/opt/smartdc/$role/build/node/bin:/opt/smartdc/$role/node_modules/.bin" >>/root/.profile
{'fraction_non_alphanumeric': 0.14642529789184236, 'fraction_numerical': 0.01466544454628781, 'mean_word_length': 5.054091539528433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3901862', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1773, 'n_words': 349}