Add hash generating bash script

This commit is contained in:
Sven Seeberg 2020-10-23 18:35:08 +02:00
parent b9c16b4dfd
commit b2ffac99f9
Signed by: sven.seeberg
GPG Key ID: 29559DD5A83806B5
1 changed files with 28 additions and 0 deletions

28
generate_hashes.sh Executable file
View File

@ -0,0 +1,28 @@
# Parameters:
# 1) Path to source file (one name per line)
# 2) Event Token
# 3) Number of rounds
CLIENT_CERT="client.crt"
CLIENT_KEY="client.key"
HOST="https://localhost/get_ids"
SRC_DIR=$(echo $PWD)
TMP_DIR=$(mktemp -d)
cd $TMP_DIR
split -l 50 -d $SRC_DIR/$1 user-list-
for f in $TMP_DIR/*
do
USERS=$(cat $f | paste -sd ',' -)
USERS=$(echo "$USERS" | sed "s/,/\",\ \"/g")
USERS="\"$USERS\""
for ROUND in $(seq 1 $3)
do
JSON="{\"event_token\": \"$2\", \"round\": $ROUND, \"user_names\": [$USERS]}"
curl -k $HOST --cert $CLIENT_CERT --key $CLIENT_KEY -H 'Content-Type: application/json' \
-d "$JSON" > /dev/null
done
done
rm -rf $TMP_DIR