-
Notifications
You must be signed in to change notification settings - Fork 270
/
entrypoint
executable file
·39 lines (31 loc) · 1.13 KB
/
entrypoint
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
#!/bin/bash
unregister() {
echo "Stopping and unregistering the GitLab runner."
gitlab-runner stop
gitlab-runner unregister --all-runners
}
update_ca() {
echo "Updating CA certificates..."
cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}"
update-ca-certificates --fresh >/dev/null
}
# Ensure that assigned uid has entry in /etc/passwd
if [ `id -u` -ge 10000 ]; then
cat /etc/passwd | sed -e "s/^gitlab-runner:/builder:/" > /tmp/passwd
echo "gitlab-runner:x:`id -u`:`id -g`:,,,:/home/gitlab-runner:/bin/bash" >> /tmp/passwd
cat /tmp/passwd > /etc/passwd
rm /tmp/passwd
fi
# gitlab-runner data directory
DATA_DIR="/etc/gitlab-runner"
CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml}
# custom certificate authority path
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt}
LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt"
if [ -f "${CA_CERTIFICATES_PATH}" ]; then
# update the ca if the custom ca is different than the current
cmp -s "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca
fi
trap unregister SIGTERM
# launch gitlab-runner passing all arguments
exec gitlab-runner "$@"