-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathfixtures.sh
More file actions
executable file
·56 lines (45 loc) · 1.12 KB
/
fixtures.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.12 KB
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
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
# shellcheck source=scripts/lib.sh
source "${SCRIPT_DIR}/lib.sh"
CODER_DEV_SHIM="${PROJECT_ROOT}/scripts/coder-dev.sh"
add_license() {
CODER_DEV_LICENSE="${CODER_DEV_LICENSE:-}"
if [[ -z "${CODER_DEV_LICENSE}" ]]; then
echo "No license provided. Please set CODER_DEV_LICENSE environment variable."
exit 1
fi
if [[ "${CODER_BUILD_AGPL:-0}" -gt "0" ]]; then
echo "Not adding a license in AGPL build mode."
exit 0
fi
NUM_LICENSES=$("${CODER_DEV_SHIM}" licenses list -o json | jq -r '. | length')
if [[ "${NUM_LICENSES}" -gt "0" ]]; then
echo "License already exists. Skipping addition."
exit 0
fi
echo -n "${CODER_DEV_LICENSE}" | "${CODER_DEV_SHIM}" licenses add -f - || {
echo "ERROR: failed to add license. Try adding one manually."
exit 1
}
exit 0
}
main() {
if [[ $# -eq 0 ]]; then
echo "Available fixtures:"
echo " license: adds the license from CODER_DEV_LICENSE"
exit 0
fi
[[ -n "${VERBOSE:-}" ]] && set -x
set -euo pipefail
case "$1" in
"license")
add_license
;;
*)
echo "Unknown fixture: $1"
exit 1
;;
esac
}
main "$@"