BjornMagnussonXA | d3104ef | 2019-03-26 12:48:46 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Remigiusz Janeczek | 9055367 | 2020-07-14 10:08:01 +0200 | [diff] [blame] | 3 | #function to load sftp servers keys to dfc app depending on KNOWN_HOSTS environment variable |
| 4 | # when KNOWN_HOSTS == "all_hosts_keys" or is not set, public keys of all sftp servers are loaded |
| 5 | # when KNOWN_HOSTS == "known_hosts_empty", empty known hosts file is created |
| 6 | # for other strings known hosts file is not created |
| 7 | function load-sftp-servers-keys() { |
| 8 | if [ -z "$KNOWN_HOSTS" ] || [ "$KNOWN_HOSTS" == "all_hosts_keys" ]; then |
| 9 | SFTP_SERVERS="$(docker ps -q --filter='name=dfc_sftp')" |
| 10 | |
| 11 | for SFTP_SERVER in $SFTP_SERVERS; do |
| 12 | HOST_NAMES=$(docker inspect -f '{{ join .NetworkSettings.Networks.dfcnet.Aliases ","}}' $SFTP_SERVER) |
| 13 | KEY_ENTRY=$(echo $HOST_NAMES "$(docker exec $SFTP_SERVER cat /etc/ssh/ssh_host_rsa_key.pub)" | |
| 14 | sed -e 's/\w*@\w*$//') |
| 15 | docker exec -u root dfc_app0 sh -c "echo $KEY_ENTRY >> /home/datafile/.ssh/known_hosts" |
| 16 | done |
| 17 | elif [ "$KNOWN_HOSTS" == "known_hosts_empty" ]; then |
| 18 | docker exec -u root dfc_app0 sh -c "touch /home/datafile/.ssh/known_hosts" |
| 19 | fi |
| 20 | } |
| 21 | |
TamasBakai | e81736c | 2019-08-23 13:31:57 +0000 | [diff] [blame] | 22 | set -x |
BjornMagnussonXA | d3104ef | 2019-03-26 12:48:46 +0000 | [diff] [blame] | 23 | |
TamasBakai | e81736c | 2019-08-23 13:31:57 +0000 | [diff] [blame] | 24 | #Start DFC app |
TamasBakai | e81736c | 2019-08-23 13:31:57 +0000 | [diff] [blame] | 25 | DOCKER_SIM_NWNAME="dfcnet" |
| 26 | echo "Creating docker network $DOCKER_SIM_NWNAME, if needed" |
Remigiusz Janeczek | 9055367 | 2020-07-14 10:08:01 +0200 | [diff] [blame] | 27 | docker network ls | grep $DOCKER_SIM_NWNAME >/dev/null || docker network create $DOCKER_SIM_NWNAME |
TamasBakai | e81736c | 2019-08-23 13:31:57 +0000 | [diff] [blame] | 28 | |
| 29 | docker-compose up -d |
| 30 | |
| 31 | DFC_APP="$(docker ps -q --filter='name=dfc_app0')" |
BjornMagnussonXA | d3104ef | 2019-03-26 12:48:46 +0000 | [diff] [blame] | 32 | |
| 33 | #Wait for initialization of docker containers for dfc app and all simulators |
| 34 | for i in {1..10}; do |
Remigiusz Janeczek | 9055367 | 2020-07-14 10:08:01 +0200 | [diff] [blame] | 35 | if [ $(docker inspect --format '{{ .State.Running }}' $DFC_APP) ]; then |
| 36 | echo "DFC app Running" |
yanhuanwang | 459a620 | 2019-09-13 14:19:05 +0200 | [diff] [blame] | 37 | |
Remigiusz Janeczek | 9055367 | 2020-07-14 10:08:01 +0200 | [diff] [blame] | 38 | load-sftp-servers-keys |
yanhuanwang | 459a620 | 2019-09-13 14:19:05 +0200 | [diff] [blame] | 39 | |
Remigiusz Janeczek | 9055367 | 2020-07-14 10:08:01 +0200 | [diff] [blame] | 40 | # enable TRACE logging of DFC |
| 41 | docker exec $DFC_APP /bin/sh -c " sed -i 's/org.onap.dcaegen2.collectors.datafile: WARN/org.onap.dcaegen2.collectors.datafile: TRACE/g' /opt/app/datafile/config/application.yaml" |
yanhuanwang | 459a620 | 2019-09-13 14:19:05 +0200 | [diff] [blame] | 42 | |
Remigiusz Janeczek | 9055367 | 2020-07-14 10:08:01 +0200 | [diff] [blame] | 43 | #enable TRACE logging of spring-framework |
| 44 | docker exec $DFC_APP /bin/sh -c " sed -i 's/org.springframework.data: ERROR/org.springframework.data: TRACE/g' /opt/app/datafile/config/application.yaml" |
| 45 | |
| 46 | docker restart $DFC_APP |
| 47 | sleep 10 |
| 48 | |
| 49 | break |
| 50 | else |
| 51 | echo sleep $i |
| 52 | sleep $i |
TamasBakai | e81736c | 2019-08-23 13:31:57 +0000 | [diff] [blame] | 53 | fi |
| 54 | done |