diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2013-08-27 08:42:40 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2013-08-27 08:42:40 -0700 |
commit | a1dfbf19b5e88897b46f4095ff3ef730eba26ba6 (patch) | |
tree | 65b49afabd2d199f4125833dc7df4f4e2fde410b /devfiles/scripts | |
parent | 01d252469b0c68422e6bb0dbb7a63217732bc56c (diff) |
Adding devfiles: various scripts and data files
Diffstat (limited to 'devfiles/scripts')
-rwxr-xr-x | devfiles/scripts/bootstrap-cassandra.sh | 26 | ||||
-rwxr-xr-x | devfiles/scripts/bootstrap-strings.sh | 32 | ||||
-rw-r--r-- | devfiles/scripts/cassandra-bootstrap.cql | 22 | ||||
-rwxr-xr-x | devfiles/scripts/compile-questions.sh | 9 | ||||
-rwxr-xr-x | devfiles/scripts/compile-videos.sh | 12 |
5 files changed, 101 insertions, 0 deletions
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 + |