mirror of https://github.com/dirtbags/moth.git
merge backup into pointsd
This commit is contained in:
parent
52d59b14a8
commit
1f799fa927
|
@ -1,7 +1,12 @@
|
||||||
00ADMIN_PKGDIR = $(TARGET)/00admin
|
00ADMIN_PKGDIR = $(TARGET)/00admin
|
||||||
|
|
||||||
|
ifndef PASSWORD
|
||||||
|
$(error PASSWORD not defined)
|
||||||
|
endif
|
||||||
|
|
||||||
00admin-install:
|
00admin-install:
|
||||||
$(call COPYTREE, packages/00admin/service, $(00ADMIN_PKGDIR)/service)
|
$(call COPYTREE, packages/00admin/service, $(00ADMIN_PKGDIR)/service)
|
||||||
|
echo "$(PASSWORD)" > $(00ADMIN_PKGDIR)/password
|
||||||
mkdir -p $(00ADMIN_PKGDIR)/sbin
|
mkdir -p $(00ADMIN_PKGDIR)/sbin
|
||||||
cp packages/00admin/sbin/* $(00ADMIN_PKGDIR)/sbin
|
cp packages/00admin/sbin/* $(00ADMIN_PKGDIR)/sbin
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
exec 2>&1
|
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
|
# Bring up the NIC; this will get us at least a link-local address, and
|
||||||
# hopefully a global address with stateless autoconfiguration.
|
# hopefully a global address with stateless autoconfiguration.
|
||||||
|
|
|
@ -17,13 +17,6 @@ set -C
|
||||||
base=${CTF_BASE:-/var/lib/ctf}
|
base=${CTF_BASE:-/var/lib/ctf}
|
||||||
www=${CTF_BASE:-/var/www}
|
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/names
|
||||||
mkdir -p $base/teams/colors
|
mkdir -p $base/teams/colors
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -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
|
|
||||||
|
|
|
@ -77,27 +77,31 @@ BEGIN {
|
||||||
tslen = 0
|
tslen = 0
|
||||||
|
|
||||||
nteams = 0;
|
nteams = 0;
|
||||||
while (1 == getline) {
|
}
|
||||||
time = $1
|
|
||||||
team = $2
|
|
||||||
cat = $3
|
|
||||||
points = int($4)
|
|
||||||
|
|
||||||
if (! start) {
|
# MAINLOOP
|
||||||
start = time
|
{
|
||||||
}
|
time = $1
|
||||||
|
team = $2
|
||||||
|
cat = $3
|
||||||
|
points = int($4)
|
||||||
|
|
||||||
if (time > (outtime + interval)) {
|
if (! start) {
|
||||||
outtime = time
|
start = time
|
||||||
output()
|
|
||||||
}
|
|
||||||
lasttime = time
|
|
||||||
|
|
||||||
teams[team] = nteams++
|
|
||||||
points_by_cat[cat] += points
|
|
||||||
points_by_cat_team[cat, team] += points
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
output()
|
||||||
|
|
||||||
# Get team colors and names
|
# Get team colors and names
|
||||||
|
@ -180,7 +184,8 @@ BEGIN {
|
||||||
print " </head>"
|
print " </head>"
|
||||||
print " <body>"
|
print " <body>"
|
||||||
print " <h1>Scoreboard</h1>"
|
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 " <table id=\"scoreboard\">"
|
||||||
print " <tr>"
|
print " <tr>"
|
||||||
print " <th>Overall</th>"
|
print " <th>Overall</th>"
|
||||||
|
|
|
@ -31,6 +31,7 @@ mcp-install: $(MCP_BUILDDIR)/build
|
||||||
$(call COPYTREE, packages/mcp/bin, $(MCP_PKGDIR)/bin)
|
$(call COPYTREE, packages/mcp/bin, $(MCP_PKGDIR)/bin)
|
||||||
cp packages/mcp/src/pointscli $(MCP_PKGDIR)/bin/
|
cp packages/mcp/src/pointscli $(MCP_PKGDIR)/bin/
|
||||||
cp packages/mcp/src/puzzles.cgi $(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/
|
cp $(MCP_BUILDDIR)/eris/eris $(MCP_PKGDIR)/bin/
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 247 B |
|
@ -1,16 +1,31 @@
|
||||||
#! /bin/sh
|
#! /bin/sh -e
|
||||||
|
|
||||||
fn=$2/$3
|
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
|
# Only do this if this score hasn't yet been recorded
|
||||||
if ! cut -d' ' -f2- $POINTS | grep -Fqx "$(cut -d' ' -f2- $fn)"; then
|
if ! cut -d' ' -f2- $POINTS | grep -Fqx "$(cut -d' ' -f2- $fn)"; then
|
||||||
cat $fn >> $POINTS && rm $fn
|
cat $fn >> $POINTS
|
||||||
|
rm $fn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Render scoreboard
|
|
||||||
if [ $POINTS -nt $SCOREBOARD ]; then
|
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
|
fi
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 215 B |
|
@ -27,7 +27,6 @@ main(int argc, char *argv[])
|
||||||
char* multicastIP; /* Arg: IP Multicast address */
|
char* multicastIP; /* Arg: IP Multicast address */
|
||||||
char* multicastPort; /* Arg: Server port */
|
char* multicastPort; /* Arg: Server port */
|
||||||
char token[100];
|
char token[100];
|
||||||
size_t tokenlen;
|
|
||||||
struct addrinfo * multicastAddr; /* Multicast address */
|
struct addrinfo * multicastAddr; /* Multicast address */
|
||||||
struct addrinfo hints = { 0 }; /* Hints for name lookup */
|
struct addrinfo hints = { 0 }; /* Hints for name lookup */
|
||||||
struct timeval timeout = { 0 };
|
struct timeval timeout = { 0 };
|
||||||
|
@ -44,7 +43,6 @@ main(int argc, char *argv[])
|
||||||
if (NULL == fgets(token, sizeof(token), stdin)) {
|
if (NULL == fgets(token, sizeof(token), stdin)) {
|
||||||
DieWithError("Unable to read token");
|
DieWithError("Unable to read token");
|
||||||
}
|
}
|
||||||
tokenlen = strlen(token);
|
|
||||||
|
|
||||||
/* Resolve destination address for multicast datagrams */
|
/* Resolve destination address for multicast datagrams */
|
||||||
hints.ai_family = PF_INET6;
|
hints.ai_family = PF_INET6;
|
||||||
|
|
|
@ -59,7 +59,7 @@ $(ECMH_BUILDDIR): $(ECMH_CACHE)
|
||||||
|
|
||||||
router-build: $(ROUTER_BUILDDIR)/ecmh-build
|
router-build: $(ROUTER_BUILDDIR)/ecmh-build
|
||||||
$(ROUTER_BUILDDIR)/ecmh-build: $(ECMH_BUILDDIR)
|
$(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
|
$(MAKE) -C $(ECMH_BUILDDIR)/tools/mtrace6
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue