Skip to content

Commit

Permalink
Merge pull request #1473 from yunkon-kim/yunkon-kim-240327-1
Browse files Browse the repository at this point in the history
Add runTF.sh to run poc-mc-net-tf container
  • Loading branch information
seokho-son authored Mar 27, 2024
2 parents c061969 + 7e1ff49 commit 9c6e49a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/exportCredentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ done < "$credentialFile"

{
echo "[default]"
echo "aws_access_key_id=$aws_access_key_id"
echo "aws_secret_access_key=$aws_secret_access_key"
echo "AWS_ACCESS_KEY_ID=$aws_access_key_id"
echo "AWS_SECRET_ACCESS_KEY=$aws_secret_access_key"
} > "$saveTo/aws_credential"

cat > "$saveTo/gcp_credential.json" << EOF
Expand All @@ -107,10 +107,10 @@ cat > "$saveTo/gcp_credential.json" << EOF
EOF

{
echo "client_id=$azure_client_id"
echo "client_secret=$azure_client_secret"
echo "tenant_id=$azure_tenant_id"
echo "subscription_id=$azure_subscription_id"
echo "ARM_CLIENT_ID=$azure_client_id"
echo "ARM_CLIENT_SECRET=$azure_client_secret"
echo "ARM_TENANT_ID=$azure_tenant_id"
echo "ARM_SUBSCRIPTION_ID=$azure_subscription_id"
} > "$saveTo/azure_credential"


Expand Down
44 changes: 44 additions & 0 deletions scripts/runTF.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

CONTAINER_NAME_READ="poc-mc-net-tf"
CONTAINER_VERSION="0.0.3"
CONTAINER_PORT="-p 8888:8888"
CONTAINER_DATA_PATH="/app/.tofu"

if [ -z "$CBTUMBLEBUG_ROOT" ]; then
SCRIPT_DIR=`dirname ${BASH_SOURCE[0]-$0}`
export CBTUMBLEBUG_ROOT=`cd $SCRIPT_DIR && cd .. && pwd`
fi

parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"

# The credential directory and file path
credential_dir="$CBTUMBLEBUG_ROOT/conf/.credtmp"
aws_credential="$credential_dir/credentials"
azure_credential="$credential_dir/credential-azure.env"
gcp_credential="$credential_dir/credential-gcp.json"

# The exported credentials from the credential.conf file
exported_aws_credential="$credential_dir/aws_credential"
exported_azure_credential="$credential_dir/azure_credential"
exported_gcp_credential="$credential_dir/gcp_credential.json"

# Check if credential files exist
if [ ! -f "$aws_credential" ] || [ ! -f "$gcp_credential" ] || [ ! -f "$azure_credential" ]; then

# Check if the exported credentials exist
if [ ! -f "$exported_aws_credential" ] || [ ! -f "$exported_gcp_credential" ] || [ ! -f "$exported_azure_credential" ]; then
./exportCredentials.sh
fi
# Move the exported credentials to the credential directory
mv $exported_aws_credential $aws_credential
mv $exported_gcp_credential $gcp_credential
mv $exported_azure_credential $azure_credential
fi

CONTAINER_ENV="--env-file $credential_dir/credentials \
--env-file $credential_dir/credential-azure.env \
--mount type=bind,source=$credential_dir/,target=/app/secrets/"

./runContainer.sh "$CONTAINER_NAME_READ" "$CONTAINER_VERSION" "$CONTAINER_PORT" "$CONTAINER_DATA_PATH" "$CONTAINER_ENV"

0 comments on commit 9c6e49a

Please sign in to comment.