moth/packages/mcp/service/pointsd/pointsd

17 lines
401 B
Bash
Executable File

#! /bin/sh
fn=$2/$3
POINTS=/var/lib/ctf/points.log
SCOREBOARD=/var/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
fi
# Render scoreboard
if [ $POINTS -nt $SCOREBOARD ]; then
/opt/mcp/bin/scoreboard < $POINTS > $SCOREBOARD.new && mv $SCOREBOARD.new $SCOREBOARD
fi