3 # ============LICENSE_START====================================================
5 # ===========================================================================
6 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7 # ===========================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END====================================================
22 # Copies of Repo data need to be added to "dats" dir for loading by push.sh
24 # Further, repo data has dates that are out of date and may have IDs not valid. We need to make
25 # sure the important data is consistent with Identities.
27 # This is expected to be run from a controlling Machine data "authz/auth/sample/cass_data" when a backup
28 # is created that is intended to be "Bootstrap Data"
30 # Date resets on key data load on the system at load time
34 ID_FILE=../data/sample.identities.dat
36 if [ -e $ID_FILE ]; then
37 if [ "$(uname -s)" = "Darwin" ]; then
38 DATE=$(date -v "+6m" "+%Y-%m-%d %H:%M:%S.000+0000")
40 DATE=$(date "+%Y-%m-%d %H:%M:%S.000+0000" -d "+6 months")
48 echo "Create default Passwords for all Identities in $CRED"
49 for ID in $(grep '|a|' $ID_FILE | sed -e "s/|.*//"); do
50 if [ "$ID" = "aaf" ]; then
51 DOMAIN="aaf.osaaf.org";
53 DOMAIN="$ID.onap.org";
56 for D in ${DOMAIN//./ }; do
57 if [ -z "$FIRST" ]; then
64 echo "$ID@$DOMAIN|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|$NS|53344|" >> $CRED
67 for ID in $(grep '|e|' $ID_FILE | sed -e "s/|.*//"); do
68 echo "$ID@people.osaaf.org|2|${DATE}|0xd993c5617486296f1b99d04de31633332b8ba1a550038e23860f9dbf0b2fcf95|Initial ID|org.osaaf.people|53344|" >> $CRED
72 echo "Scrubbing user_roles not in $ID_FILE"
74 ## Covering for when scrubbing in cass_init versus a Backup
75 if [ -d "dats" ]; then
76 for D in ns ns_attrib perm role config artifact; do
77 if [ -e "dats/$D.dat" ]; then
87 for ID in $(grep -v "#" $ID_FILE | awk -F\| '{print $1}' | grep -v "^$"); do
88 grep "$ID@" dats/user_role.dat >> user_role.dat
94 cat user_role.dat | awk -F\| '{print $1}' | sort -u > $UR
95 cat dats/user_role.dat | awk -F\| '{print $1}' | sort -u > $DUR
97 echo "Removed IDs from user_roles"
98 diff $UR $DUR | grep "^>" | sort -u
103 sed "s/\(^.*|\)\(.*|\)\(.*|\)\(.*\)/\1${DATE}|\3\4/" tmp > user_role.dat
105 if [ -n "$REMOVE_DATS" ]; then
109 echo $0 requires access to $ID_FILE