#!/bin/bash

set -e

secrets_dir="/etc/crypta/secrets/cm-tools"
mkdir -p "$secrets_dir"

oauth_token_file="$secrets_dir/yav-oauth"

if [ ! -f "$oauth_token_file" ]; then
    echo ""
    echo "PLACE YOUR OAUTH TOKEN TO $oauth_token_file"
    echo ""
    echo "Run as yourself (not as root):"
    echo "sudo chown -R \"\$(whoami)\" $secrets_dir"
    echo "yav oauth > $oauth_token_file"
    echo "sudo /usr/share/crypta-cm-tools/get-secrets.sh  # or wait for 5 minutes"
fi
