#!/usr/bin/env bash

dir="$1"

# Create local copies of files that this image needs
ln --force ../../../scripts/ansible/roles/apt_sources/templates/trusty-sources.list $dir
ln --force ../../../scripts/ansible/roles/apt_sources/files/llvm-snapshot.gpg.key $dir
ln --force ../../../scripts/ansible/roles/apt_sources/files/ubuntu-toolchain-r-test.asc $dir

cat > $dir/credentials <<EOF
[s3DataIncoming]
aws_access_key_id = $(vault read -field=access_key secret/aws/ingest_chum)
aws_secret_access_key = $(vault read -field=secret_access_key secret/aws/ingest_chum)

[zooxChum]
aws_access_key_id = $(vault read -field=access_key secret/aws/ingest_chum)
aws_secret_access_key = $(vault read -field=secret_access_key secret/aws/ingest_chum)

[ingestPipedreamScheduler]
aws_access_key_id = $(vault read -field=access_key secret/aws/ingest_pipedream_scheduler)
aws_secret_access_key = $(vault read -field=secret_access_key secret/aws/ingest_pipedream_scheduler)

[s3DiskIncoming]
aws_access_key_id = $(vault read -field=access_key secret/aws/ingest_chum)
aws_secret_access_key = $(vault read -field=secret_access_key secret/aws/ingest_chum)

[RobotDataPlatform]
aws_access_key_id = $(vault read -field=access_key secret/aws/robot_data_platform)
aws_secret_access_key = $(vault read -field=secret_access_key secret/aws/robot_data_platform)
EOF

cat > $dir/github_credentials <<EOF
[ingestGithub]
username = $(vault read -field=username secret/github/ingest)
token = $(vault read -field=token secret/github/ingest)
EOF
