-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsetup
executable file
·66 lines (58 loc) · 2.2 KB
/
setup
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
#!/bin/bash
set -e
if [[ $(uname) == 'Darwin' ]]; then
READLINK_BIN="greadlink"
else
READLINK_BIN="readlink"
fi
#cwd=$(pwd)
if [[ -z "${GARDENER_WEBSITE_GENERATOR_PATH}" ]]; then
generatorRepoPath="$(${READLINK_BIN} -f "$(dirname "${0}")/..")"
else
generatorRepoPath="$(${READLINK_BIN} -f "${GARDENER_WEBSITE_GENERATOR_PATH}")";
fi
if [[ ! -d "${generatorRepoPath}" ]]; then
echo "website-generator directory path is invalid ['$generatorRepoPath']. Set GARDENER_WEBSITE_GENERATOR_PATH to a correct path or run from website-generator cloned repo."
exit 1
fi
if [[ -z "${GARDENER_WEBSITE_PATH}" ]]; then
# Fallback to "gardener" repo cloned as peer directory to "website-generator"
websiteRepoPath="$(${READLINK_BIN} -f "$(dirname "${0}")/../../website")"
else
websiteRepoPath="$(${READLINK_BIN} -f "${GARDENER_WEBSITE_PATH}")";
fi
if [[ -z "${GARDENER_DOCUMENTATION_PATH}" ]]; then
# Fallback to "documentation" repo cloned as peer directory to "website-generator"
contentRepoPath="$(${READLINK_BIN} -f "$(dirname "${0}")/../../documentation")"
else
contentRepoPath="$(${READLINK_BIN} -f "${GARDENER_DOCUMENTATION_PATH}")";
fi
if [[ -z "${GH_INTERNAL_USERNAME}" ]]; then
ghorg="gardener"
fi
if [[ ! -d "${contentRepoPath}" ]]; then
echo "gardener/documentation repo is not available locally."
git clone "https://github.com/${ghorg}/documentation.git" "${contentRepoPath}"
fi
if [[ ! -d "${websiteRepoPath}" ]]; then
echo "gardener/website repo is not available locally."
git clone "https://github.com/${ghorg}/website.git" "${websiteRepoPath}"
fi
content=${contentRepoPath}/website
# create symlink hugo/content -> /documentation/website, if it doesn't exists
#
if [[ ! -L "hugo/content" ]]; then
echo 'linking hugo/content <==> /documentation/website'
cd hugo
if [[ $(uname) == 'Darwin' ]]; then
ln -s "$content" "$generatorRepoPath/hugo/content"
else
# WSL users: If the script fails with "You do not have sufficient privilege to perform this operation.", enable the Windows Developer Mode.
if [[ -z "${WSL_DISTRO_NAME}" ]]; then
../scripts/mklink.sh "$content" "$(wslpath -w "$content")"
fi
fi
symlinkoutput="$(ls -lt "$content")"
echo "${symlinkoutput}"
cd ..
fi