State of competition can now happen in the cloud

This commit is contained in:
Aaron McPhall 2012-05-31 00:29:36 -04:00
parent c1fa983fc7
commit e8a56ba418
5 changed files with 74 additions and 0 deletions

View File

@ -5,6 +5,8 @@ if [ $# -ne 1 ]; then
exit 64
fi
escape () {
sed 's/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/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

25
packages/mcp/bin/backup Executable file
View File

@ -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

38
packages/mcp/bin/backup-pass Executable file
View File

@ -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

View File

@ -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

BIN
packages/mcp/www/bkup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B