From 3075e0a0553ffead7c3b97322b86aac85dc691ce Mon Sep 17 00:00:00 2001 From: Aaron McPhall Date: Thu, 31 May 2012 00:29:36 -0400 Subject: [PATCH] State of competition can now happen in the cloud --- packages/mcp/bin/addteam | 9 +++++++++ packages/mcp/bin/backup | 25 +++++++++++++++++++++++ packages/mcp/bin/backup-pass | 38 +++++++++++++++++++++++++++++++++++ packages/mcp/bin/new-contest | 2 ++ packages/mcp/www/bkup.png | Bin 0 -> 215 bytes 5 files changed, 74 insertions(+) create mode 100755 packages/mcp/bin/backup create mode 100755 packages/mcp/bin/backup-pass create mode 100644 packages/mcp/www/bkup.png diff --git a/packages/mcp/bin/addteam b/packages/mcp/bin/addteam index c2b7204..c7db910 100755 --- a/packages/mcp/bin/addteam +++ b/packages/mcp/bin/addteam @@ -5,6 +5,8 @@ if [ $# -ne 1 ]; then exit 64 fi + + escape () { sed 's/&/\&/g;s//\>/g' } @@ -15,6 +17,13 @@ set -C base=${CTF_BASE:-/var/lib/ctf} www=${CTF_BASE:-/var/www} +if which backup-team >/dev/null 2>&1 ; then + if [ ! -e $base/pass ]; then + echo "\nYou should consider running backup-pass or new-contest." + echo "DBTL Altocumulus™ backup system will not work without it.\n" + fi +fi + mkdir -p $base/teams/names mkdir -p $base/teams/colors diff --git a/packages/mcp/bin/backup b/packages/mcp/bin/backup new file mode 100755 index 0000000..e4c929f --- /dev/null +++ b/packages/mcp/bin/backup @@ -0,0 +1,25 @@ +#! /bin/sh -e + +base=${CTF_BASE:-/var/lib/ctf} +www=${CTF_BASE:-/var/www} +pass=$base/pass +img=$www/bkup.png +time=$(date +%s) +output=bkup-${time}.png + +if [ ! -e $img -o ! -e $pass ]; then + exit 0 +fi + +# clean up all other backup images +if ls $www/bkup-*.png >/dev/null 2>&1 ; then + rm $www/bkup-*.png +fi + +# This is a tested method. +#(cat $img; tar -cf - $base 2>/dev/null | gzip -c ) > $www/$output + +# This is not a tested method. +(cat $img; tar -cvf - $base 2>/dev/null | gzip -c | rc4 3< $pass) > $www/$output + +echo $output diff --git a/packages/mcp/bin/backup-pass b/packages/mcp/bin/backup-pass new file mode 100755 index 0000000..4c34961 --- /dev/null +++ b/packages/mcp/bin/backup-pass @@ -0,0 +1,38 @@ +#! /bin/sh -e + +trap "stty echo; echo ''; echo 'Passfile not written'; exit 42" 1 2 3 15 + +askpass () { + echo "Password: " + stty -echo + read pass1 + echo "Retype password: " + read pass2 + stty echo + if [ "${pass1}" = "${pass2}" ]; then + echo "Got it.\n" + return 0 + else + echo "Authentication token manipulation error.\n" + return 1 + fi +} + +base=${CTF_BASE:-/var/lib/ctf} +passfile=$base/pass + +if [ -e $passfile ]; then + echo "\nDanger! Danger!\n" + echo "Wipes out current passfile. It's ok as long as note the current" + echo "timestamp ($(date +%s)) and the new pass will be applied on the" + echo "next scoreboard update.\n" +fi + +echo "Enter passphrase for backups" +echo "To exit, press ctrl+c" +until askpass; do true; done + +echo -e "${pass1}" > $passfile +echo "Passfile written" +stty echo + diff --git a/packages/mcp/bin/new-contest b/packages/mcp/bin/new-contest index f62635d..02e7e1f 100755 --- a/packages/mcp/bin/new-contest +++ b/packages/mcp/bin/new-contest @@ -23,6 +23,8 @@ rm -rf /var/lib/ctf/points.tmp rm -rf /var/lib/ctf/tanks rm -rf /var/lib/ctf/teams +backup-pass + sv u tokend sv u pointsd sv u puzzled diff --git a/packages/mcp/www/bkup.png b/packages/mcp/www/bkup.png new file mode 100644 index 0000000000000000000000000000000000000000..89c959ce31cff7748a37faccf83d2ab37ca25463 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y}!3HGH?)<(INHG=%xjQkeJ16rJ$YD$Jc6VX; z4}uH!E}sk(2`_PtC~?lu%}vcKVF<~{ELH%by!;Y{M1_LVs;Zn+Jq3l3jKsWbh06R= zg|z%4g{0KXymW=cg2bW{h5R&yl8jUZm&~G)q{Q@Mg`~vf?9u{-;>zNZ)Lgw~%y!3t zR>*j|IEHXsPfj?%^v~D;2o$>ySolj8H2#-RVrcMWdNDUVO#!Hm!PC{xWt~$(699XK BLni