-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
42 lines (32 loc) · 1.55 KB
/
docker-entrypoint.sh
File metadata and controls
42 lines (32 loc) · 1.55 KB
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
39
40
41
42
#!/bin/bash
mkdir -p /var/lib/go-server/addons /var/log/go-server /etc/go /go-addons $ARTIFACTS_LOCATION
chown -R go:go /var/lib/go-server /var/log/go-server /etc/go /go-addons /var/go cruise-config.xml $ARTIFACTS_LOCATION
if [ ! -f "/var/go/.ssh/id_rsa" ] ; then
mkdir -p /var/go/.ssh
ssh-keygen -C "docker-go-cdserver" -N '' -f /var/go/.ssh/id_rsa
chown -R go:go /var/go/.ssh
eval "$(ssh-agent -s)"
ssh-add /var/go/.ssh/id_rsa
# Dump the public key so we can use it later (e.g. accessing a Git repo using ssh)
echo "######"
echo "# The go-cdserver SSH public key"
cat /var/go/.ssh/id_rsa.pub
echo "######"
#http://askubuntu.com/questions/123072/ssh-automatically-accept-keys
ssh-keyscan -H bitbucket.org >> /var/go/.ssh/known_hosts
ssh-keyscan -H github.com >> /var/go/.ssh/known_hosts
fi
if [ ! -f "/etc/go/cruise-config.xml" ] ; then
cp cruise-config.xml /etc/go/cruise-config.xml
# Setup auto registration for agents.
AGENT_KEY="${AGENT_KEY:-7fd926aa8323}"
[[ -n "$AGENT_KEY" ]] && sed -i -e 's/agentAutoRegisterKey="[^"]*" *//' -e 's#\(<server\)\(.*artifactsdir.*\)#\1 agentAutoRegisterKey="'$AGENT_KEY'"\2#' /etc/go/cruise-config.xml
[[ -n "$SERVER_ID" ]] && sed -i -e 's/serverId="[^"]*" *//' -e 's#\(<server\)\(.*artifactsdir.*\)#\1 serverId="'$SERVER_ID'"\2#' /etc/go/cruise-config.xml
fi
if [ ! -f "/etc/go/cipher.xml" ] ; then
# Setup cipher for encryption.
[[ -n "$CIPHER" ]] && echo $CIPHER > /etc/go/cipher
fi
chown -R go:go /etc/go/
echo "Starting go-server with agent key $AGENT_KEY"
exec gosu go /etc/init.d/go-server start