Instrumental | f95fc5f | 2018-11-21 16:06:17 -0600 | [diff] [blame] | 1 | # echo -n "Password:" |
| 2 | # read -s PWD |
| 3 | # echo |
| 4 | echo `date` |
| 5 | ENV=DOCKER |
| 6 | |
| 7 | CQLSH="/usr/bin/cqlsh -k authz" |
| 8 | |
| 9 | cd dats |
| 10 | if [ "$*" = "" ]; then |
| 11 | DATA="" |
| 12 | for Tdat in `ls *.dat`; do |
| 13 | if [ -s "${Tdat}" ]; then |
| 14 | DATA="$DATA ${Tdat%.dat}" |
| 15 | fi |
| 16 | done |
| 17 | else |
| 18 | DATA="$*" |
| 19 | fi |
| 20 | cd - |
| 21 | |
| 22 | echo "You are about to REPLACE the data in the $ENV DB for the following tables:" |
| 23 | echo "$DATA" |
| 24 | echo -n 'If you are VERY sure, type "YES": ' |
| 25 | read YES |
| 26 | |
| 27 | if [ ! "$YES" = "YES" ]; then |
| 28 | echo 'Exiting ...' |
| 29 | exit |
| 30 | fi |
| 31 | |
| 32 | UPLOAD="" |
| 33 | for 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+ |
Instrumental | 66424b3 | 2019-04-13 08:27:16 -0500 | [diff] [blame] | 38 | "approval"|"artifact"|"cred"|"ns"|"x509"|"role"|"notified") |
Instrumental | f95fc5f | 2018-11-21 16:06:17 -0600 | [diff] [blame] | 39 | $CQLSH -e "truncate $T" |
Instrumental | a6baa19 | 2018-11-28 06:53:55 -0600 | [diff] [blame] | 40 | UPLOAD="$UPLOAD "$T |
| 41 | ;; |
| 42 | "history") |
| 43 | $CQLSH -e "truncate $T" |
| 44 | DO_HISTORY=true |
Instrumental | f95fc5f | 2018-11-21 16:06:17 -0600 | [diff] [blame] | 45 | ;; |
| 46 | *) |
| 47 | $CQLSH -e "truncate $T; COPY authz.${T} FROM 'dats/${T}.dat' WITH DELIMITER='|'" |
| 48 | ;; |
| 49 | esac |
| 50 | fi |
| 51 | done |
| 52 | |
| 53 | if [ ! "$UPLOAD" = "" ]; then |
Instrumental | a6baa19 | 2018-11-28 06:53:55 -0600 | [diff] [blame] | 54 | cd dats |
| 55 | java -Dcadi_prop_files=../authBatch.props -DCASS_ENV=$ENV -jar ../aaf-auth-batch-*-full.jar Upload $UPLOAD |
| 56 | cd - |
| 57 | fi |
| 58 | |
| 59 | if [ "$DO_HISTORY" = "true" ]; then |
| 60 | $CQLSH -e "COPY authz.history FROM 'dats/history.dat' WITH DELIMITER='|'" |
Instrumental | f95fc5f | 2018-11-21 16:06:17 -0600 | [diff] [blame] | 61 | fi |
| 62 | echo `date` |