Update DCAE Startup Info
[aaf/authz.git] / auth / auth-cass / cass_init / restore.sh
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+
38       "approval"|"artifact"|"cred"|"ns"|"x509"|"role"|"notified")
39         $CQLSH -e  "truncate $T"
40         UPLOAD="$UPLOAD "$T
41         ;;
42       "history")
43         $CQLSH -e "truncate $T"
44         DO_HISTORY=true
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
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='|'"
61 fi
62 echo `date`