From 014baa6529975341a314ed7bcc21d1dd639daab5 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Tue, 27 Aug 2013 08:42:40 -0700 Subject: Adding devfiles: various scripts and data files --- devfiles/scripts/bootstrap-cassandra.sh | 26 ++++++++++++++++++++++++++ devfiles/scripts/bootstrap-strings.sh | 32 ++++++++++++++++++++++++++++++++ devfiles/scripts/cassandra-bootstrap.cql | 22 ++++++++++++++++++++++ devfiles/scripts/compile-questions.sh | 9 +++++++++ devfiles/scripts/compile-videos.sh | 12 ++++++++++++ 5 files changed, 101 insertions(+) create mode 100755 devfiles/scripts/bootstrap-cassandra.sh create mode 100755 devfiles/scripts/bootstrap-strings.sh create mode 100644 devfiles/scripts/cassandra-bootstrap.cql create mode 100755 devfiles/scripts/compile-questions.sh create mode 100755 devfiles/scripts/compile-videos.sh (limited to 'devfiles/scripts') diff --git a/devfiles/scripts/bootstrap-cassandra.sh b/devfiles/scripts/bootstrap-cassandra.sh new file mode 100755 index 0000000..220bd03 --- /dev/null +++ b/devfiles/scripts/bootstrap-cassandra.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +## +## This script deletes all Cassandra data and creates and populates the +## ColumnFamilies needed to start the Growth Process. +## + +export TOOLS=`awk -F= '/jesterpm\.buildtools\.root/ { print $2 }' $HOME/.jesterpm-build-tools.properties` +export DEVFILES=$(dirname $0) + +$TOOLS/scripts/setup-cassandra.sh + +# Bootstrap keyspace +TEMPFILE=`mktemp` +cat $DEVFILES/cassandra-bootstrap.cql > $TEMPFILE + +# Fill with questions +./compile-questions.sh >> $TEMPFILE + +# Fill with videos +./compile-videos.sh >> $TEMPFILE + +# GO! +#cat $TEMPFILE | less +cassandra-cli < $TEMPFILE +rm $TEMPFILE diff --git a/devfiles/scripts/bootstrap-strings.sh b/devfiles/scripts/bootstrap-strings.sh new file mode 100755 index 0000000..9552dcb --- /dev/null +++ b/devfiles/scripts/bootstrap-strings.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +## +## This script clears the strings ColumnFamily and then rebuilds it. +## + +export TOOLS=`awk -F= '/jesterpm\.buildtools\.root/ { print $2 }' $HOME/.jesterpm-build-tools.properties` +export DEVFILES=$(dirname $0) + +TEMPFILE=`mktemp` + +cat > $TEMPFILE << EOF +use GROW; + +drop column family strings; + +create column family strings + with key_validation_class = 'UTF8Type' + and comparator = 'UTF8Type' + and default_validation_class = 'UTF8Type'; +EOF + +# Fill with questions +./compile-questions.sh >> $TEMPFILE + + +# Fill with videos +./compile-videos.sh >> $TEMPFILE + +# GO! +cassandra-cli < $TEMPFILE +rm $TEMPFILE diff --git a/devfiles/scripts/cassandra-bootstrap.cql b/devfiles/scripts/cassandra-bootstrap.cql new file mode 100644 index 0000000..c7d6de8 --- /dev/null +++ b/devfiles/scripts/cassandra-bootstrap.cql @@ -0,0 +1,22 @@ +drop keyspace GROW; + +create keyspace GROW + with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy' + and strategy_options = {replication_factor:1}; + +use GROW; + +create column family strings + with key_validation_class = 'UTF8Type' + and comparator = 'UTF8Type' + and default_validation_class = 'UTF8Type'; + +create column family assessments + with key_validation_class = 'UTF8Type' + and comparator = 'UTF8Type' + and default_validation_class = 'UTF8Type'; + +create column family training + with key_validation_class = 'UTF8Type' + and comparator = 'UTF8Type' + and default_validation_class = 'UTF8Type'; diff --git a/devfiles/scripts/compile-questions.sh b/devfiles/scripts/compile-questions.sh new file mode 100755 index 0000000..16be5b1 --- /dev/null +++ b/devfiles/scripts/compile-questions.sh @@ -0,0 +1,9 @@ +# Dump Cassandra commands to setup questions +for i in $DEVFILES/questions/*.json; do + id=`basename $i .json` + echo "set strings['/questions/${id}']['value'] = '" + cat $i + echo "';" +done + + diff --git a/devfiles/scripts/compile-videos.sh b/devfiles/scripts/compile-videos.sh new file mode 100755 index 0000000..4ed8ad0 --- /dev/null +++ b/devfiles/scripts/compile-videos.sh @@ -0,0 +1,12 @@ +# Dump video data into Cassandra form. + +for i in $DEVFILES/videos/*; do + level=`basename $i` + for j in $i/*.json; do + id=`basename $j .json` + echo "set strings['/training/${level}']['${id}'] = '" + cat $j + echo "';" + done +done + -- cgit v1.2.3