2022-05-31 13:56:44 +02:00
#!/bin/bash
if [ " $1 " != "get" ] ; then
echo " Usage: $0 get "
exit 1
fi
baseDir( ) {
# see https://stackoverflow.com/questions/59895
SOURCE = ${ BASH_SOURCE [0] }
while [ -h " $SOURCE " ] ; do # resolve $SOURCE until the file is no longer a symlink
DIR = $( cd -P " $( dirname " $SOURCE " ) " >/dev/null 2>& 1 && pwd )
SOURCE = $( readlink " $SOURCE " )
[ [ $SOURCE != /* ] ] && SOURCE = $DIR /$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR = $( cd -P " $( dirname " $SOURCE " ) /.. " >/dev/null 2>& 1 && pwd )
echo $DIR
}
BASE = $( baseDir)
cd $BASE
source lib/functions.sh
assertVarsNotEmpty SITE_ID || exit 1
2022-05-31 14:03:07 +02:00
PARAMS = " $( cat) "
2022-05-31 13:56:44 +02:00
GITHOST = $( echo " $PARAMS " | grep "^host=" | sed 's/host=\(.*\)/\1/g' )
2022-05-31 14:02:09 +02:00
fetchVarsFromVault GIT_PASSWORD
2022-05-31 13:56:44 +02:00
2022-05-31 14:02:09 +02:00
if [ -z " ${ GIT_PASSWORD } " ] ; then
2022-05-31 13:56:44 +02:00
log ERROR "Git password not found."
exit 1
fi
2022-05-31 14:03:07 +02:00
cat <<EOF
2022-05-31 13:56:44 +02:00
protocol = https
host = $GITHOST
username = bk-${ SITE_ID }
2022-05-31 14:02:09 +02:00
password = ${ GIT_PASSWORD }
2022-05-31 13:56:44 +02:00
EOF