2010-09-07 21:31:23 -06:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "Usage: $0 TEAM" 1>&2
|
|
|
|
exit 64
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Don't overwrite files
|
|
|
|
set -C
|
|
|
|
|
2010-09-23 18:23:00 -06:00
|
|
|
base=${CTF_BASE:-/var/lib/ctf}
|
2010-09-13 12:23:39 -06:00
|
|
|
|
2010-09-09 15:14:39 -06:00
|
|
|
# Assign a color. I spent two days selecting this color pallette for
|
|
|
|
# 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-09-09 15:14:39 -06:00
|
|
|
case $(expr $nteams % 15) in
|
|
|
|
0) color=8c7a69 ;;
|
|
|
|
1) color=7f7062 ;;
|
|
|
|
2) color=79614b ;;
|
|
|
|
3) color=a59281 ;;
|
|
|
|
4) color=a59485 ;;
|
|
|
|
5) color=4a4f5e ;;
|
|
|
|
6) color=454955 ;;
|
|
|
|
7) color=343c52 ;;
|
|
|
|
8) color=696f82 ;;
|
|
|
|
9) color=6b7182 ;;
|
|
|
|
10) color=516b55 ;;
|
|
|
|
11) color=4b614f ;;
|
|
|
|
12) color=395d3f ;;
|
|
|
|
13) color=6d8c72 ;;
|
|
|
|
14) color=708c75 ;;
|
|
|
|
*)
|
|
|
|
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}/.
|
2010-09-07 21:31:23 -06:00
|
|
|
hash=$(echo "$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"
|