blob: c11865b85bd0a03f3adfc56bab56a5f3f96c4ebc [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"
Instrumentala6baa192018-11-28 06:53:55 -060040 UPLOAD="$UPLOAD "$T
41 ;;
42 "history")
43 $CQLSH -e "truncate $T"
44 DO_HISTORY=true
Instrumentalf95fc5f2018-11-21 16:06:17 -060045 ;;
46 *)
47 $CQLSH -e "truncate $T; COPY authz.${T} FROM 'dats/${T}.dat' WITH DELIMITER='|'"
48 ;;
49 esac
50 fi
51done
52
53if [ ! "$UPLOAD" = "" ]; then
Instrumentala6baa192018-11-28 06:53:55 -060054 cd dats
55 java -Dcadi_prop_files=../authBatch.props -DCASS_ENV=$ENV -jar ../aaf-auth-batch-*-full.jar Upload $UPLOAD
56 cd -
57fi
58
59if [ "$DO_HISTORY" = "true" ]; then
60 $CQLSH -e "COPY authz.history FROM 'dats/history.dat' WITH DELIMITER='|'"
Instrumentalf95fc5f2018-11-21 16:06:17 -060061fi
62echo `date`