Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vault issue 107 #109

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
96 changes: 96 additions & 0 deletions scripts/start-vault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

scriptdir="$(dirname "$0")"
cd "$scriptdir"

PID_PATH_NAME="../airavata-mft/vault/vault-pid"
LOG_FILE="../airavata-mft/vault/vault.log"
VAULT_PATH_NAME="../airavata-mft/vault/vault"

URL=""
ZIPFILE=""

if [[ $OSTYPE == *"darwin"* ]];
then
URL="https://releases.hashicorp.com/vault/1.14.1/vault_1.14.1_darwin_amd64.zip"
ZIPFILE="vault_1.14.1_darwin_amd64.zip"
elif [[ $OSTYPE == *"linux"* ]];
then
URL="https://releases.hashicorp.com/vault/1.14.1/vault_1.14.1_linux_amd64.zip"
ZIPFILE="vault_1.14.1_linux_amd64.zip"
else
echo "As of now, airavata-mft only supports linux and mac"
exit 0
fi

if [ ! -f $PID_PATH_NAME ];
then
mkdir -p ../airavata-mft/vault/keys
elif pgrep -x "vault" > /dev/null
then
# This is the condition where vault-pid file exists and
# vault is actually running
# Then this block will be executed

# Reference: https://askubuntu.com/questions/157779/how-to-determine-whether-a-process-is-running-or-not-and-make-use-it-to-make-a-c
echo "Vault is already running ..."
exit 0
fi

# if vault-pid file exists or not but the vault executable itself does not exist
# then the following code will be executed
if [ ! -f $VAULT_PATH_NAME ]
then
curl -O $URL
unzip -o $ZIPFILE -d ../airavata-mft/vault
rm $ZIPFILE
fi

# if the control structure reaches here, we have the vault executable ready to run
nohup ../airavata-mft/vault/vault server -config=../config.hcl > $LOG_FILE 2>&1 &
echo $! > $PID_PATH_NAME # $! contains the pid of the recently started background process
echo "Vault started"


# Reference:
# https://stackoverflow.com/a/3232433


#while True; do
# if [ -f $LOG_FILE ]; then
# lineCount=$(wc -l < $LOG_FILE | tr -d ' ' | tr -d '\n')
# lineCount="$(echo -e "${lineCount}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# if [[ $lineCount -gt 4 ]]; then
# echo "Log file is being updated";
# break;
# fi
# fi
#done
#
#while IFS=':' read -r Key Value;
#do
# Key="$(echo -e "${Key}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# Value="$(echo -e "${Value}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
# if [ "$Key" == "Api Address" ]; then
# echo "cat $LOG_FILE"
# echo "export VAULT_ADDR='$Value'"
# fi
#done < $LOG_FILE

33 changes: 33 additions & 0 deletions scripts/stop-vault.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

scriptdir="$(dirname "$0")"
cd "$scriptdir"

PID_PATH_NAME="../airavata-mft/vault/vault-pid"
LOG_PATH_NAME="../airavata-mft/vault/vault.log"
NEW_PATH_NAME="../airavata-mft/vault/backup.log"

if [ -f $PID_PATH_NAME ]; then
PID=$(cat $PID_PATH_NAME);
kill $PID;
echo "Vault stopped"
rm -rf $PID_PATH_NAME
mv $LOG_PATH_NAME $NEW_PATH_NAME
fi
14 changes: 14 additions & 0 deletions scripts/vault-config.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
storage "file" {
path = "../airavata-mft/vault/vault-data"
}

listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = "true"
}

disable_mlock = true

api_addr = "http://127.0.0.1:8200"
cluster_addr = "https://127.0.0.1:8201"
ui = true
7 changes: 7 additions & 0 deletions services/secret-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
<module>client</module>
<module>server</module>
</modules>
<dependencies>
<dependency>
<groupId>com.bettercloud</groupId>
<artifactId>vault-java-driver</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
<artifactId>mft-secret-service</artifactId>


Expand Down
10 changes: 10 additions & 0 deletions services/secret-service/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
<artifactId>dozer</artifactId>
<version>${dozer}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
</dependencies>

<build>
Expand Down
Loading
  NODES
COMMUNITY 2
Note 1
Project 4
USERS 1