blob: 0374e61996458f265225b2ae97d2a9f17682609b [file] [log] [blame]
Instrumentalbc299c02018-09-25 06:42:31 -05001#!/bin/bash
2#
3# Copies of Repo data need to be added to "dats" dir for loading by push.sh
4#
5# Further, repo data has dates that are out of date. We need to update reasonable
6# expiration dates
7#
8
9DIR=/opt/app/aaf/cass_init
10cd $DIR/dats
11ID_FILE=$DIR/opt/app/aaf/cass_init/
12
13 if [ -e $ID_FILE ]; then
14 if [ "$(uname -s)" = "Darwin" ]; then
15 DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -v "+6m")
16 else
17 DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
18 fi
19 echo $DATE
20 CRED="cred.dat"
21 # Enter for People
22 echo "Default Passwords for People"
23 for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
24 if [ "$ID" = "aaf" ]; then
25 DOMAIN="aaf.osaaf.org";
26 else
27 DOMAIN="$ID.onap.org";
28 fi
29 unset FIRST
30 for D in ${DOMAIN//./ }; do
31 if [ -z "$FIRST" ]; then
32 NS="$D"
33 FIRST="N"
34 else
35 NS="$D.$NS"
36 fi
37 done
38 echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED
39 done
40
41 for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
42 echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
43 done
44
45 mv user_role.dat tmp
46 sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > user_role.dat
47
48 for DAT in ns perm role ns_attrib user_role cred; do
49 $DOCKER container cp $DAT.dat aaf_cass:/tmp/$DAT.dat
50 $DOCKER exec aaf_cass bash /usr/bin/cqlsh -k authz -e "COPY authz.$DAT FROM '/tmp/$DAT.dat' WITH DELIMITER='|'"
51 $DOCKER exec -t aaf_cass rm /tmp/$DAT.dat
52 done
53 rm $CRED
54 mv tmp user_role.dat
55 else
56 echo DInstall requires access to 'identities.dat'
57 fi
58 cd -
59