#! /bin/sh : ${BASE:=/var/lib/ctf/p2} mkdir -p $BASE if ! [ -f $BASE/salt ]; then dd if=/dev/urandom count=1 | md5sum - > $BASE/salt fi clear printf '\017' read salt < $BASE/salt esc () { printf '%s' "$*" | sed 's/[^-0-9A-Za-z ]/_/g; s/ /+/g' } newteam () { echo '== Team Creation ==' echo echo -n 'What would you like your team to be called (3-12 chars)? ' read -r name echo namelen=$(printf "%s" "$name" | wc -c) if [ $namelen -lt 3 ] || [ $namelen -gt 12 ]; then echo 'Invalid name length' return fi hash=$(printf '%s %s' "$salt" "$name" | md5sum | cut -b 1-8) if [ -d $BASE/$hash ]; then echo "That name is already in use. Try another one." return fi mkdir $BASE/$hash printf '%s' "$name" > $BASE/$hash/.name cat < " read -r answer case "$answer" in \?|help) cat < $fn echo "You get $points more points in the $cat category." # run puzzles.cgi # update scoreboard fi done