Move Cloudify's password update and plugins upload to
[dcaegen2/deployments.git] / cm-container / scripts / set-admin-password.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ============LICENSE_END=========================================================
17 # Runs at deployment time to set cloudify's admin password
18
19 set -x
20
21 # Wait for Cloudify Manager to come up
22 while ! /scripts/cloudify-ready.sh
23 do
24     echo "Waiting for CM to come up"
25     sleep 15
26 done
27
28 set +x
29
30 # Expect Cloudify password to be in file mounted from Kubernetes secret,
31 # but allow overriding by CMPASS environment variable,
32 # and if not provided, use the default
33 CMPASS=${CMPASS:-$(cat /opt/onap/cm-secrets/password 2>/dev/null)}
34 CMPASS=${CMPASS:-admin}
35
36 echo "Set Cloudify's admin password"
37 cd /opt/manager
38 cfy_manager --reset_admin_password $CMPASS || ./env/bin/python reset_admin.py -p $CMPASS
39
40 echo "Set the password used by the cfy client"
41 cfy profile set -p $CMPASS
42
43 echo "Cloudify password set"