-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·40 lines (31 loc) · 1.02 KB
/
docker-entrypoint.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
39
40
#!/bin/bash
# Variables:
# SCHEDULE (optional)
# GIT_REMOTE
# GIT_BRANCH (optional)
# CLONE_DIR (optional, default /repo)
# GIT_USERNAME (optional)
# GIT_PASSWORD (optional)
# GIT_PASSWORD_PATH (optional)
set -o nounset -o errexit
if [[ -n "${GIT_PASSWORD:-}" ]]; then
if [[ -z "${GIT_PASSWORD_PATH:-}" ]]; then
export GIT_PASSWORD_PATH="$(mktemp)"
chmod go-rwx "$GIT_PASSWORD_PATH"
fi
echo -n "$GIT_PASSWORD" >"$GIT_PASSWORD_PATH"
fi
git config --global init.defaultBranch main
if [[ -n "${GIT_PASSWORD_PATH:-}" ]]; then
git config --global credential.helper "/cred-helper.sh '$GIT_USERNAME' '$GIT_PASSWORD_PATH'"
elif [[ -n "${GIT_USERNAME:-}" ]]; then
git config --global credential.helper "/cred-helper.sh '$GIT_USERNAME'"
fi
if [[ -z "${CLONE_DIR:-}" ]]; then
CLONE_DIR="/repo"
fi
/update.sh "$CLONE_DIR" "$GIT_REMOTE" "${GIT_BRANCH:-}"
if [[ -n "${SCHEDULE:-}" ]]; then
echo "$SCHEDULE /update.sh '$CLONE_DIR' '$GIT_REMOTE' '${GIT_BRANCH:-}'" >/var/spool/cron/crontabs/root
exec crond -fL /dev/stderr
fi