mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 06:00:06 +02:00
chore: explicitly ask for key path
This commit is contained in:
parent
892c5a4575
commit
b3926751ad
@ -15,7 +15,7 @@
|
||||
"good": "^7.2.0",
|
||||
"good-console": "^6.4.0",
|
||||
"good-squeeze": "^5.0.2",
|
||||
"graphi": "^2.2.1",
|
||||
"graphi": "^2.3.0",
|
||||
"hapi": "^16.1.0",
|
||||
"hoek": "^4.1.1",
|
||||
"joi": "^10.6.0",
|
||||
|
79
setup.sh
79
setup.sh
@ -1,9 +1,44 @@
|
||||
#!/bin/bash
|
||||
set -e -o pipefail
|
||||
|
||||
help() {
|
||||
echo
|
||||
echo 'Usage ./setup.sh ~/path/to/TRITON_PRIVATE_KEY'
|
||||
echo
|
||||
echo 'Checks that your Triton and Docker environment is sane and configures'
|
||||
echo 'an environment file to use.'
|
||||
echo
|
||||
echo 'TRITON_PRIVATE_KEY is the filesystem path to an SSH private key'
|
||||
echo 'used to connect to Triton.'
|
||||
echo
|
||||
}
|
||||
|
||||
# Check for correct configuration
|
||||
check() {
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
tput rev # reverse
|
||||
tput bold # bold
|
||||
echo 'Please provide a path to a SSH private key to access Triton.'
|
||||
tput sgr0 # clear
|
||||
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
tput rev # reverse
|
||||
tput bold # bold
|
||||
echo 'SSH private key for Triton is unreadable.'
|
||||
tput sgr0 # clear
|
||||
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Assign args to named vars
|
||||
TRITON_PRIVATE_KEY_PATH=$1
|
||||
|
||||
command -v docker >/dev/null 2>&1 || {
|
||||
echo
|
||||
tput rev # reverse
|
||||
@ -46,20 +81,36 @@ check() {
|
||||
echo TRITON_KEY_PATH=${TRITON_CREDS_PATH}/key.pem >> _env
|
||||
echo TRITON_CERT=$(cat "${DOCKER_CERT_PATH}"/cert.pem | tr '\n' '#') >> _env
|
||||
echo TRITON_CERT_PATH=${TRITON_CREDS_PATH}/cert.pem >> _env
|
||||
echo SDC_KEY=$(cat "${TRITON_PRIVATE_KEY_PATH}" | tr '\n' '#') >> _env
|
||||
echo SDC_KEY_PUB=$(cat "${TRITON_PRIVATE_KEY_PATH}.pub" | tr '\n' '#') >> _env
|
||||
echo >> _env
|
||||
|
||||
for file in ~/.ssh/*.pub
|
||||
do
|
||||
SDC_KEY=$(ssh-keygen -E md5 -lf ${file} | awk '{print $2}' | awk -F"MD5:" '{print $2}')
|
||||
if [ "$SDC_KEY" == "$SDC_KEY_ID" ]
|
||||
then
|
||||
echo SDC_KEY_PUB=$(cat "${file}" | tr '\n' '#') >> _env
|
||||
priv_file=$(echo "${file}" | awk -F".pub" '{print $1}')
|
||||
echo SDC_KEY=$(cat "${priv_file}" | tr '\n' '#') >> _env
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# default behavior
|
||||
check
|
||||
# ---------------------------------------------------
|
||||
# parse arguments
|
||||
|
||||
# Get function list
|
||||
funcs=($(declare -F -p | cut -d " " -f 3))
|
||||
|
||||
until
|
||||
if [ ! -z "$1" ]; then
|
||||
# check if the first arg is a function in this file, or use a default
|
||||
if [[ " ${funcs[@]} " =~ " $1 " ]]; then
|
||||
cmd=$1
|
||||
shift 1
|
||||
else
|
||||
cmd="check"
|
||||
fi
|
||||
|
||||
$cmd "$@"
|
||||
if [ $? == 127 ]; then
|
||||
help
|
||||
fi
|
||||
|
||||
exit
|
||||
else
|
||||
help
|
||||
fi
|
||||
do
|
||||
echo
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user