-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
34 lines (25 loc) · 873 Bytes
/
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
#!/usr/bin/env bash
set -e
if [[ -z ${GH_RUNNER_TOKEN} ]];
then
echo "Environment variable 'GH_RUNNER_TOKEN' is not set"
exit 1
fi
if [[ -z ${GH_REPOSITORY} ]];
then
echo "Environment variable 'GH_REPOSITORY' is not set"
exit 1
fi
# generate random password
# silent fail because it wont be able override password on restart
newPass=$(pwgen -s1 20)
printf "runner\n${newPass}\n${newPass}\n" | passwd 2> /dev/null || echo
# print runner version
echo "github runner version: $(./config.sh --version)"
echo "github runner commit: $(./config.sh --commit)"
workDir=/tmp/_work/$(pwgen -s1 5)
mkdir -p ${workDir}
echo "Runner working directory: ${workDir}"
# can fail if already configured
/runner/config.sh --unattended --url ${GH_REPOSITORY} --token ${GH_RUNNER_TOKEN} --labels ${GH_RUNNER_LABELS} --replace --work ${workDir} || echo
exec /runner/run.sh