<commit_before>#!/bin/bash

set -e

if [ "$1" = 'apiserver' ]; then

	if [ -z "$ETCD_ADDR" ]; then 
		ETCD_ADDR="localhost:4001"
	fi

	if [ -z "$KUBERNETES_ADDR" ]; then 
		KUBERNETES_ADDR="https://localhost:6443"
	fi

	if [ -z "$CORS_ORIGIN_ADDR" ]; then 
		CORS_ORIGIN_ADDR="http://localhost"
	fi
	
	if [ -z "$PREFIX" ]; then 
		PREFIX="/api/"
	fi

	if [ -z "$TIMEOUT" ]; then 
		TIMEOUT="30"
	fi

	if [ -z "$INGRESS" ]; then 
		INGRESS="NodePort"
	fi

	if [ -z "$VOLUME_PATH" ]; then 
		VOLUME_PATH="/volumes"
	fi

	if [ -z "$VOLUME_NAME" ]; then 
		VOLUME_NAME="global"
	fi

	if [ -z "$SMTP_HOST" ]; then 
		SMTP_HOST="smtp.ncsa.illinois.edu"
	fi

	if [ -z "$SMTP_PORT" ]; then 
		SMTP_PORT=25
	fi
	if [ -z "$SUPPORT_EMAIL" ]; then 
		SUPPORT_EMAIL=<EMAIL>
	fi

	if [ -z "$ADMIN_PASSWORD" ]; then
		ADMIN_PASSWORD=`strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'`
	fi

cat << EOF > /apiserver.conf
[Server]
Port=30001
Origin=$CORS_ORIGIN_ADDR
VolDir=$VOLUME_PATH
VolName=$VOLUME_NAME
SpecsDir=/specs
Timeout=$TIMEOUT
Prefix=$PREFIX
Ingress=$INGRESS
Domain=$DOMAIN

[DefaultLimits]
CpuMax=2000
CpuDefault=1000
MemMax=8196
MemDefault=100
StorageDefault=10

[Etcd]
Address=$ETCD_ADDR

[Kubernetes]
Address=$KUBERNETES_ADDR
Username=admin
Password=<PASSWORD>

[Email]
Host=$SMTP_HOST
Port=$SMTP_PORT
SupportEmail=$SUPPORT_EMAIL

EOF

	if [ -z "$SPEC_GIT_REPO" ]; then 
		SPEC_GIT_REPO=https://github.com/nds-org/ndslabs-specs
	fi

	if [ -z "$SPEC_GIT_BRANCH" ]; then 
		SPEC_GIT_BRANCH=master
	fi

	git clone -b $SPEC_GIT_BRANCH $SPEC_GIT_REPO /specs

	echo $ADMIN_PASSWORD > /password.txt
	umask 0

	/apiserver -conf /apiserver.conf -v 4 -passwd $ADMIN_PASSWORD

else<commit_msg>Updated support email format<commit_after>#!/bin/bash

set -e

if [ "$1" = 'apiserver' ]; then

	if [ -z "$ETCD_ADDR" ]; then 
		ETCD_ADDR="localhost:4001"
	fi

	if [ -z "$KUBERNETES_ADDR" ]; then 
		KUBERNETES_ADDR="https://localhost:6443"
	fi

	if [ -z "$CORS_ORIGIN_ADDR" ]; then 
		CORS_ORIGIN_ADDR="http://localhost"
	fi
	
	if [ -z "$PREFIX" ]; then 
		PREFIX="/api/"
	fi

	if [ -z "$TIMEOUT" ]; then 
		TIMEOUT="30"
	fi

	if [ -z "$INGRESS" ]; then 
		INGRESS="NodePort"
	fi

	if [ -z "$VOLUME_PATH" ]; then 
		VOLUME_PATH="/volumes"
	fi

	if [ -z "$VOLUME_NAME" ]; then 
		VOLUME_NAME="global"
	fi

	if [ -z "$SMTP_HOST" ]; then 
		SMTP_HOST="smtp.ncsa.illinois.edu"
	fi

	if [ -z "$SMTP_PORT" ]; then 
		SMTP_PORT=25
	fi
	if [ -z "$SUPPORT_EMAIL" ]; then 
		SUPPORT_EMAIL=<EMAIL>
	fi

	if [ -z "$ADMIN_PASSWORD" ]; then
		ADMIN_PASSWORD=`strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'`
	fi

cat << EOF > /apiserver.conf
[Server]
Port=30001
Origin=$CORS_ORIGIN_ADDR
VolDir=$VOLUME_PATH
VolName=$VOLUME_NAME
SpecsDir=/specs
Timeout=$TIMEOUT
Prefix=$PREFIX
Ingress=$INGRESS
Domain=$DOMAIN

[DefaultLimits]
CpuMax=2000
CpuDefault=1000
MemMax=8196
MemDefault=100
StorageDefault=10

[Etcd]
Address=$ETCD_ADDR

[Kubernetes]
Address=$KUBERNETES_ADDR
Username=admin
Password=<PASSWORD>

[Email]
Host=$SMTP_HOST
Port=$SMTP_PORT
SupportEmail=NDS Labs <$SUPPORT_EMAIL>

EOF

	if [ -z "$SPEC_GIT_REPO" ]; then 
		SPEC_GIT_REPO=https://github.com/nds-org/ndslabs-specs
	fi

	if [ -z "$SPEC_GIT_BRANCH" ]; then 
		SPEC_GIT_BRANCH=master
	fi

	git clone -b $SPEC_GIT_BRANCH $SPEC_GIT_REPO /specs

	echo $ADMIN_PASSWORD > /password.txt
	umask 0

	/apiserver -conf /apiserver.conf -v 4 -passwd $ADMIN_PASSWORD

else
{'fraction_non_alphanumeric': 0.15093240093240093, 'fraction_numerical': 0.022727272727272728, 'mean_word_length': 4.0337243401759535, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 4, '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': '625024', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1497, 'n_words': 304}