forked from odavid/jenkins-jnlp-slave
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·34 lines (32 loc) · 1.09 KB
/
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
#!/bin/bash
set -e -o pipefail
if [ "$(id -u)" == "0" ]; then
# To enable docker cloud based on docker socket,
# we need to add jenkins user to the docker group
if [ -S /var/run/docker.sock ]; then
DOCKER_SOCKET_OWNER_GROUP_ID=$(stat -c %g /var/run/docker.sock)
groupadd -for -g ${DOCKER_SOCKET_OWNER_GROUP_ID} docker
id jenkins -G -n | grep docker || usermod -aG docker jenkins
fi
dirs=(
'/home/jenkins/tools'
'/home/jenkins/.m2'
'/home/jenkins/.gradle'
'/home/jenkins/.gradle/caches'
'/home/jenkins/.gradle/caches/modules-2'
'/home/jenkins/.gradle/native'
'/home/jenkins/.gradle/wrapper'
'/home/jenkins/.coursier'
'/home/jenkins/.ivy'
'/home/jenkins/.sbt'
'/home/jenkins'
)
for d in ${dirs[@]}; do
if [[ -d $d ]] && [[ "$(stat -c %u $d)" != "$(id -u jenkins)" ]]; then
echo "chown jenkins:jenkins $d"
chown jenkins:jenkins $d
echo "chown jenkins:jenkins $d... Done"
fi
done
fi
exec gosu jenkins "jenkins-slave" "$@"