-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.sh
executable file
·69 lines (57 loc) · 3.29 KB
/
install.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
set -e
EXT_GIT_PROVIDER="${GITPROVIDER:-"azuredevops"}"
EXT_GIT_REPO_URL="${CLONEURL:-"required"}"
EXT_GIT_USERNAME="${USERNAME:-"user"}"
EXT_GIT_PREBUILD_PAT="${CLONESECRET:-""}"
EXT_GIT_LOCAL_PATH="${FOLDER:-"/workspace/external-repos"}"
EXT_GIT_USER_PAT="${USERSECRET:-""}"
EXT_GIT_CLONE_TIMEOUT="${TIMEOUT:-"30m"}"
EXT_GIT_BRANCH="${BRANCH:-"main"}"
EXT_GIT_OPTIONS="${OPTIONS:-""}"
EXT_GIT_SCALAR="${SCALAR:-"false"}"
EXT_GIT_SPARSECHECKOUT="${SPARSECHECKOUT:-""}"
EXT_GIT_TELEMETRY="${TELEMETRYSOURCE:-"none"}"
EXT_GIT_AZURE_CLIENT_ID="${CLIENTID:-""}"
EXT_GIT_AZURE_TENANT_ID="${TENANTID:-""}"
EXT_GIT_OIDC_PREBUILD="false"
if [ -n "${EXT_GIT_AZURE_CLIENT_ID}" ] && [ -n "${EXT_GIT_AZURE_TENANT_ID}" ]; then
EXT_GIT_OIDC_PREBUILD="true"
fi
if [ "$(id -u)" -ne 0 ]; then
echo 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi
# Change to the directory where this script is located
cd "$(dirname "$0")"
# Install our scripts to the devcontainer
cp ./scripts/external-git /usr/local/bin
chmod a+rx /usr/local/bin/external-git
mkdir -p /usr/local/external-repository-feature
chmod +r /usr/local/external-repository-feature
cp ./scripts/clone.sh /usr/local/external-repository-feature
cp ./scripts/setup-user.sh /usr/local/external-repository-feature
cp ./scripts/commit-msg.sh /usr/local/external-repository-feature
# Write the variables.sh script
echo "EXT_GIT_PROVIDER=\"${EXT_GIT_PROVIDER}\"" > /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_REPO_URL=\"${EXT_GIT_REPO_URL}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_LOCAL_PATH=\"${EXT_GIT_LOCAL_PATH}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_USERNAME=\"${EXT_GIT_USERNAME}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_USER_PAT=\"${EXT_GIT_USER_PAT}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_PREBUILD_PAT=\"${EXT_GIT_PREBUILD_PAT}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_CLONE_TIMEOUT=\"${EXT_GIT_CLONE_TIMEOUT}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_BRANCH=\"${EXT_GIT_BRANCH}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_OPTIONS=\"${EXT_GIT_OPTIONS}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_SCALAR=\"${EXT_GIT_SCALAR}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_SPARSECHECKOUT=\"${EXT_GIT_SPARSECHECKOUT}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_TELEMETRY=\"${EXT_GIT_TELEMETRY}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_AZURE_CLIENT_ID=\"${EXT_GIT_AZURE_CLIENT_ID}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_AZURE_TENANT_ID=\"${EXT_GIT_AZURE_TENANT_ID}\"" >> /usr/local/external-repository-feature/variables.sh
echo "EXT_GIT_OIDC_PREBUILD=\"${EXT_GIT_OIDC_PREBUILD}\"" >> /usr/local/external-repository-feature/variables.sh
# Make the scripts executable
chmod +rx /usr/local/external-repository-feature/*.sh
cat /usr/local/external-repository-feature/variables.sh
# Create the Git config file templates
cp ./scripts/*.config /usr/local/external-repository-feature
chmod +r /usr/local/external-repository-feature/*.config
exit 0