From 10a05e8d6908566a8dc003ad0cb17632296fb375 Mon Sep 17 00:00:00 2001 From: MO Root Date: Thu, 30 Mar 2017 12:18:56 +0200 Subject: [PATCH] mo-cms-groupmin --- mop/admin/Makefile | 4 ++-- mop/admin/mo-cms-groupmin.sh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 mop/admin/mo-cms-groupmin.sh diff --git a/mop/admin/Makefile b/mop/admin/Makefile index c166c3d..b404a24 100644 --- a/mop/admin/Makefile +++ b/mop/admin/Makefile @@ -5,9 +5,9 @@ DIRS+=mop/admin PROGS+=$(addprefix $(o)/mop/admin/,\ md5crypt \ mo-backup \ - mo-cms-users \ + mo-cms-users mo-cms-groupmin \ mo-create-contestants mo-create-logins mo-create-public \ - mo-upload-contestants mo-upload-logins mo-help-upload-logins mo-upload-public \ + mo-upload-contestants mo-upload-logins mo-help-upload-logins mo-upload-public mo-upload-skeleton \ mo-get-users) $(o)/mop/admin/md5crypt: $(o)/mop/admin/md5crypt.o $(LIBUCW) diff --git a/mop/admin/mo-cms-groupmin.sh b/mop/admin/mo-cms-groupmin.sh new file mode 100755 index 0000000..a7d7b95 --- /dev/null +++ b/mop/admin/mo-cms-groupmin.sh @@ -0,0 +1,20 @@ +#!/bin/bash +#create JSON group min score parameters for CMS + +[ -d "$1" ] && cd "$1" + +in=`mktemp` +out=`mktemp` + +ls | grep '^[0-9][0-9][a-z]\?\.in' | sed 's/\.in$//' > "$in" +ls | grep '^[0-9][0-9][a-z]\?\.out' | sed 's/\.out$//' > "$out" + +diff "$in" "$out" >&2 || echo WARNING: diff between input and output! >&2 + +#using input +< "$in" sed 's/[a-z]$//' | sort -nu | while read i; do + count="`grep "^$i" < "$in" | wc -l`" + echo "[1,$count]" +done | sed 's/^/ /; 1s/^/[\n/; s/$/,/; $s/,$/\n]/' + +rm -f "$in" "$out" -- 2.39.5