blob: 768cf4c7e38edee8fa5f3333318fa1969e48760d [file] [log] [blame]
Instrumentalf95fc5f2018-11-21 16:06:17 -06001# echo -n "Password:"
2# read -s PWD
3# echo
4echo `date`
5ENV=DOCKER
6
7CQLSH="/usr/bin/cqlsh -k authz"
8
9cd dats
10if [ "$*" = "" ]; then
11 DATA=""
12 for Tdat in `ls *.dat`; do
13 if [ -s "${Tdat}" ]; then
14 DATA="$DATA ${Tdat%.dat}"
15 fi
16 done
17else
18 DATA="$*"
19fi
20cd -
21
22echo "You are about to REPLACE the data in the $ENV DB for the following tables:"
23echo "$DATA"
24echo -n 'If you are VERY sure, type "YES": '
25read YES
26
27if [ ! "$YES" = "YES" ]; then
28 echo 'Exiting ...'
29 exit
30fi
31
32UPLOAD=""
33for T in $DATA; do
34 if [ -s "dats/${T}.dat" ]; then
35 echo $T
36 case "$T" in
37 # 2.1.14 still has NULL problems for COPY. Fixed in 2.1.15+
38 "approval"|"artifact"|"cred"|"ns"|"x509"|"role")
39 $CQLSH -e "truncate $T"
40 UPLOAD="$UPLOAD dats/"$T
41 ;;
42 *)
43 $CQLSH -e "truncate $T; COPY authz.${T} FROM 'dats/${T}.dat' WITH DELIMITER='|'"
44 ;;
45 esac
46 fi
47done
48
49if [ ! "$UPLOAD" = "" ]; then
50 java -DCASS_ENV=$ENV -jar aaf-auth-batch-*-full.jar Upload $UPLOAD
51fi
52echo `date`