Skip to content

Commit

Permalink
Add small menu for loading contest dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj authored Sep 12, 2023
1 parent f565fd6 commit 30c24b9
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions provision-contest/ansible/roles/mysql_server/files/load-db
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
#!/bin/sh

if [ -z "$1" ]
then
echo "Usage load-db [name]"
echo ".sql.gz will be appended"
exit 1
DIR="/home/domjudge/db-dumps"
choice=""
if [ -z "$1" ]; then
set -- $(ls $DIR)
echo $@
ind=0
for i in $@; do
echo "${ind}) $i"
: $((ind+=1))
done
while true; do
read -p "Which database should be loaded? " db
ind=0
for i in $@; do
if [ "$ind" = "$db" ]; then
choice="$i"
break
fi
: $((ind+=1))
done
if [ -n "$choice" ]; then
break
fi
done
else
if [ "$1"="-h" ]
then
echo "Usage load-db [name]"
echo ".sql.gz will be appended"
exit 1
fi
choice="${1}.tar.gz"
fi

FILE="/home/domjudge/db-dumps/${1}.sql.gz"
FILE="$DIR/${choice}"

if [ ! -f "${FILE}" ]
then
echo "Error. File ${FILE} not found"
exit 1
echo "Error. File ${FILE} not found"
exit 1
fi

pv "${FILE}" | gunzip | sudo mysql domjudge

0 comments on commit 30c24b9

Please sign in to comment.