forked from Cimpress-MCP/docker-git2consul
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.sh
40 lines (32 loc) · 1.19 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
if [ -n "$CFG" ]
then
echo "$CFG" > /etc/git2consul.d/config.json
fi
#echo "REPO: $GIT_REPO"
sed -i -e "s|GIT_REPO|$GIT_REPO|" /etc/git2consul.d/config.json
#cat /etc/git2consul.d/config.json
sed -i -e "s|NAMESPACE|$NAMESPACE|" /etc/git2consul.d/config.json
#cat /etc/git2consul.d/config.json
sed -i -e "s|GIT_SOURCEROOT|$GIT_SOURCEROOT|" /etc/git2consul.d/config.json
if [ -n "$IDENC" ]
then
ID=$(echo $IDENC |base64 -d)
IDPUB=$(echo $IDPUBENC |base64 -d)
fi
if [ -n "$ID" ]
then
echo "Adding SSH Keys to agent"
mkdir ~/.ssh
echo "$ID" > ~/.ssh/id_rsa_git2consul
echo "$IDPUB" > ~/.ssh/id_rsa_git2consul.pub
eval "$(ssh-agent -s)"
chmod 600 -R ~/.ssh/id_rsa_git2consul
ssh-add ~/.ssh/id_rsa_git2consul
echo -e "StrictHostKeyChecking no\nUserKnownHostsFile=/dev/null" > ~/.ssh/config
echo -e "Host git2consul\n\tIdentityFile ~/.ssh/id_rsa_git2consul" >> ~/.ssh/config
fi
echo -e "$(date) starting git2consul. found these env vars: \nCFG:$CFG \nGIT_REPO:$GIT_REPO \nIDPUB:$IDPUB \nCONSUL_ENDPOINT:$CONSUL_ENDPOINT \nCONSUL_PORT:$CONSUL_PORT"
#cat /etc/git2consul.d/config.json
#
exec /usr/bin/node /usr/lib/node_modules/git2consul --config-file /etc/git2consul.d/config.json $@