2010-09-07 21:31:23 -06:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: $0 TEAM" 1>&2
|
|
|
|
exit 64
|
|
|
|
fi
|
|
|
|
|
2012-05-30 22:29:36 -06:00
|
|
|
|
|
|
|
|
2010-09-23 23:27:14 -06:00
|
|
|
escape () {
|
|
|
|
sed 's/&/\&/g;s/</\</g;s/>/\>/g'
|
|
|
|
}
|
|
|
|
|
2010-09-07 21:31:23 -06:00
|
|
|
# Don't overwrite files
|
|
|
|
set -C
|
|
|
|
|
2010-09-23 18:23:00 -06:00
|
|
|
base=${CTF_BASE:-/var/lib/ctf}
|
2010-09-23 23:27:14 -06:00
|
|
|
www=${CTF_BASE:-/var/www}
|
2010-09-13 12:23:39 -06:00
|
|
|
|
2012-05-30 22:29:36 -06:00
|
|
|
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
|
|
|
|
|
2010-09-29 17:38:54 -06:00
|
|
|
mkdir -p $base/teams/names
|
|
|
|
mkdir -p $base/teams/colors
|
|
|
|
|
2012-05-30 18:04:24 -06:00
|
|
|
[ -f $base/teams/salt ] || dd if=/dev/urandom count=1 2>/dev/null | md5sum | cut -b 1-8 > $base/teams/salt
|
|
|
|
salt=$(cat $base/teams/salt)
|
2012-05-18 22:03:53 -06:00
|
|
|
|
2010-10-22 17:09:00 -06:00
|
|
|
# Assign a color. I spent weeks selecting a color pallette that
|
|
|
|
# wouldn't be hell on people with protanopia. Please don't change these
|
|
|
|
# colors.
|
2010-09-13 12:23:39 -06:00
|
|
|
nteams=$(ls $base/teams/names/ | wc -l)
|
2010-10-22 17:09:00 -06:00
|
|
|
case $(expr $nteams % 10) in
|
|
|
|
0) color=a6cee3;;
|
|
|
|
1) color=1f78b4;;
|
|
|
|
2) color=b2df8a;;
|
|
|
|
3) color=33a02c;;
|
|
|
|
4) color=fb9a99;;
|
|
|
|
5) color=e31a1c;;
|
|
|
|
6) color=fdbf6f;;
|
|
|
|
7) color=ff7f00;;
|
|
|
|
8) color=cab2d6;;
|
|
|
|
9) color=6a3d9a;;
|
2010-09-09 15:14:39 -06:00
|
|
|
*)
|
|
|
|
echo 'ERROR ERROR' 1>&2
|
|
|
|
echo 'DOES NOT COMPUTE' 1>&2
|
|
|
|
exit 69
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Compute hash of team name; they'll use this for everything in the
|
|
|
|
# contest instead of their team name, which makes stuff much easier on
|
|
|
|
# me since all team hashes are in the set /[0-9a-f]{8}/.
|
2012-05-30 18:04:24 -06:00
|
|
|
hash=$(printf "%s:%s" $salt "$1" | md5sum | cut -b 1-8)
|
2010-09-09 15:14:39 -06:00
|
|
|
|
2010-09-13 12:23:39 -06:00
|
|
|
echo "$1" > $base/teams/names/$hash
|
|
|
|
echo "$color" > $base/teams/colors/$hash
|
2010-09-09 15:14:39 -06:00
|
|
|
|
2010-09-13 12:23:39 -06:00
|
|
|
echo "Registered with hash: $hash"
|