-
Notifications
You must be signed in to change notification settings - Fork 0
/
mvn-entrypoint.sh
39 lines (33 loc) · 1.13 KB
/
mvn-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
#! /bin/bash -eu
set -o pipefail
# Copy files from /usr/share/maven/ref into ${MAVEN_CONFIG}
# So the initial ~/.m2 is set with expected content.
# Don't override, as this is just a reference setup
copy_reference_file() {
local root="${1}"
local f="${2%/}"
local logfile="${3}"
local rel="${f/${root}/}" # path relative to /usr/share/maven/ref/
echo "$f" >> "$logfile"
echo " $f -> $rel" >> "$logfile"
if [[ ! -e ${MAVEN_CONFIG}/${rel} || $f = *.override ]]
then
echo "copy $rel to ${MAVEN_CONFIG}" >> "$logfile"
mkdir -p "${MAVEN_CONFIG}/$(dirname "${rel}")"
cp -r "${f}" "${MAVEN_CONFIG}/${rel}";
fi;
}
copy_reference_files() {
local log="$MAVEN_CONFIG/copy_reference_file.log"
if (sh -c "mkdir -p \"$MAVEN_CONFIG\" && touch \"${log}\"" > /dev/null 2>&1)
then
echo "--- Copying files at $(date)" >> "$log"
find /usr/share/maven/ref/ -type f -exec bash -eu -c 'copy_reference_file /usr/share/maven/ref/ "$1" "$2"' _ {} "$log" \;
else
echo "Can not write to ${log}. Wrong volume permissions? Carrying on ..."
fi
}
export -f copy_reference_file
copy_reference_files
unset MAVEN_CONFIG
exec "$@"