entrypoint 1.4 KB
Newer Older
fuyanbin's avatar
fuyanbin committed
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

if [[ ! -e /.obsutil_init ]]
then
    obsutil config -i=5PHLX4PTSPAJCDPTSUC8 -k=rXPzf7gewOsNwO2hqJq8nii4zzzL6bO5zDVIFJK2 -e=obs.cn-north-4.myhuaweicloud.com
    touch /.obsutil_init
fi

# 注册 GitLab Runner
if [[ ! -e /.gitlab-runner_init ]]
then
fuyanbin's avatar
fuyanbin committed
12
    gitlab-runner register --non-interactive --url "https://web.lueluesay.top/git/" --registration-token "$GITLAB_TOKEN" --executor "shell" --description "$RUNNER_NAME" --tag-list "$TAG_LIST" --run-untagged="true" --locked="false"
fuyanbin's avatar
fuyanbin committed
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
43
44
45
46
47
48
49
    touch /.gitlab-runner_init
fi


# 检查注册是否成功
if [ $? -ne 0 ]; then
  echo "GitLab Runner 注册失败"
  exit 1
fi

# 原有的entrypoint文件内容
# 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"

update_ca() {
  echo "Updating CA certificates..."
  cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}"
  update-ca-certificates --fresh >/dev/null
}

if [ -f "${CA_CERTIFICATES_PATH}" ]; then
  # update the ca if the custom ca is different than the current
  cmp --silent "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca
fi

# launch gitlab-runner passing all arguments
gitlab-runner run --user=root --working-directory="$GILAB_RUNNER_WORKDIR"

while :;
do
    sleep 3600 &
    wait
done