merge backup into pointsd

This commit is contained in:
Neale Pickett 2012-06-05 23:56:29 -06:00
parent 1f6975e791
commit 103babad5a
12 changed files with 54 additions and 98 deletions

View File

@ -1,7 +1,12 @@
00ADMIN_PKGDIR = $(TARGET)/00admin
ifndef PASSWORD
$(error PASSWORD not defined)
endif
00admin-install:
$(call COPYTREE, packages/00admin/service, $(00ADMIN_PKGDIR)/service)
echo "$(PASSWORD)" > $(00ADMIN_PKGDIR)/password
mkdir -p $(00ADMIN_PKGDIR)/sbin
cp packages/00admin/sbin/* $(00ADMIN_PKGDIR)/sbin

View File

@ -2,7 +2,9 @@
exec 2>&1
echo 'root:$1$i/EeZyl6$5C6Z8s0ftEdTKFLUli1wP1' | chpasswd --encrypted
read password < /opt/00admin/password
printf 'root:%s' "$password" | chpasswd --md5
# Bring up the NIC; this will get us at least a link-local address, and
# hopefully a global address with stateless autoconfiguration.

View File

@ -17,13 +17,6 @@ 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

View File

@ -1,25 +0,0 @@
#! /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

View File

@ -1,38 +0,0 @@
#! /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

@ -77,27 +77,31 @@ BEGIN {
tslen = 0
nteams = 0;
while (1 == getline) {
time = $1
team = $2
cat = $3
points = int($4)
}
if (! start) {
start = time
}
# MAINLOOP
{
time = $1
team = $2
cat = $3
points = int($4)
if (time > (outtime + interval)) {
outtime = time
output()
}
lasttime = time
teams[team] = nteams++
points_by_cat[cat] += points
points_by_cat_team[cat, team] += points
if (! start) {
start = time
}
if (time > (outtime + interval)) {
outtime = time
output()
}
lasttime = time
teams[team] = nteams++
points_by_cat[cat] += points
points_by_cat_team[cat, team] += points
}
END {
output()
# Get team colors and names
@ -180,7 +184,8 @@ BEGIN {
print " </head>"
print " <body>"
print " <h1>Scoreboard</h1>"
print "<p id=\"debug\"></p>"
print " <p id=\"debug\"></p>"
print " <img src=\"backup.png?" NR "\" alt=\"\" style=\"display: none;\" height=\"1\" width=\"1\">"
print " <table id=\"scoreboard\">"
print " <tr>"
print " <th>Overall</th>"

View File

@ -31,6 +31,7 @@ mcp-install: $(MCP_BUILDDIR)/build
$(call COPYTREE, packages/mcp/bin, $(MCP_PKGDIR)/bin)
cp packages/mcp/src/pointscli $(MCP_PKGDIR)/bin/
cp packages/mcp/src/puzzles.cgi $(MCP_PKGDIR)/bin/
cp packages/mcp/src/tea $(MCP_PKGDIR)/bin/
cp $(MCP_BUILDDIR)/eris/eris $(MCP_PKGDIR)/bin/

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

View File

@ -1,16 +1,31 @@
#! /bin/sh
#! /bin/sh -e
fn=$2/$3
POINTS=/var/lib/ctf/points.log
SCOREBOARD=/var/www/scoreboard.html
WWW=${CTF_BASE:-/var/www}
BASE=${CTF_BASE:-/var/lib/ctf}
OPT=${CTF_BASE:-/opt}
POINTS=$BASE/points.log
BACKUP=$WWW/backup.png
SCOREBOARD=$WWW/scoreboard.html
# Only do this if this score hasn't yet been recorded
if ! cut -d' ' -f2- $POINTS | grep -Fqx "$(cut -d' ' -f2- $fn)"; then
cat $fn >> $POINTS && rm $fn
cat $fn >> $POINTS
rm $fn
fi
# Render scoreboard
if [ $POINTS -nt $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD
# Generate new backup
(
cat bkup.png;
tar cvf - $BASE | gzip -c | $OPT/00admin/bin/tea 3< $OPT/00admin/password
) > $BACKUP.new
mv $BACKUP.new $BACKUP
# Render scoreboard
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new
mv $SCOREBOARD.new $SCOREBOARD
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

View File

@ -27,7 +27,6 @@ main(int argc, char *argv[])
char* multicastIP; /* Arg: IP Multicast address */
char* multicastPort; /* Arg: Server port */
char token[100];
size_t tokenlen;
struct addrinfo * multicastAddr; /* Multicast address */
struct addrinfo hints = { 0 }; /* Hints for name lookup */
struct timeval timeout = { 0 };
@ -44,7 +43,6 @@ main(int argc, char *argv[])
if (NULL == fgets(token, sizeof(token), stdin)) {
DieWithError("Unable to read token");
}
tokenlen = strlen(token);
/* Resolve destination address for multicast datagrams */
hints.ai_family = PF_INET6;

View File

@ -59,7 +59,7 @@ $(ECMH_BUILDDIR): $(ECMH_CACHE)
router-build: $(ROUTER_BUILDDIR)/ecmh-build
$(ROUTER_BUILDDIR)/ecmh-build: $(ECMH_BUILDDIR)
$(MAKE) -C $(ECMH_BUILDDIR)/src ECMH_VERSION=dbtl-git STRIP=$(STRIP)
$(MAKE) -C $(ECMH_BUILDDIR)/src ECMH_VERSION=dbtl-git STRIP=echo
$(MAKE) -C $(ECMH_BUILDDIR)/tools/mtrace6
touch $@