File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ SCRIPT_DIR=$( dirname " ${BASH_SOURCE[0]} " )
4
+ # shellcheck source=scripts/lib.sh
5
+ source " ${SCRIPT_DIR} /lib.sh"
6
+
7
+ CODER_DEV_SHIM=" ${PROJECT_ROOT} /scripts/coder-dev.sh"
8
+
9
+ add_license () {
10
+ CODER_DEV_LICENSE=" ${CODER_DEV_LICENSE:- } "
11
+ if [[ -z " ${CODER_DEV_LICENSE} " ]]; then
12
+ echo " No license provided. Please set CODER_DEV_LICENSE environment variable."
13
+ exit 1
14
+ fi
15
+
16
+ if [[ " ${CODER_BUILD_AGPL:- 0} " -gt " 0" ]]; then
17
+ echo " Not adding a license in AGPL build mode."
18
+ exit 0
19
+ fi
20
+
21
+ NUM_LICENSES=$( " ${CODER_DEV_SHIM} " licenses list -o json | jq -r ' . | length' )
22
+ if [[ " ${NUM_LICENSES} " -gt " 0" ]]; then
23
+ echo " License already exists. Skipping addition."
24
+ exit 0
25
+ fi
26
+
27
+ echo -n " ${CODER_DEV_LICENSE} " | " ${CODER_DEV_SHIM} " licenses add -f - || {
28
+ echo " ERROR: failed to add license. Try adding one manually."
29
+ exit 1
30
+ }
31
+
32
+ exit 0
33
+ }
34
+
35
+ main () {
36
+ if [[ $# -eq 0 ]]; then
37
+ echo " Available fixtures:"
38
+ echo " license: adds the license from CODER_DEV_LICENSE"
39
+ exit 0
40
+ fi
41
+
42
+ [[ -n " ${VERBOSE:- } " ]] && set -x
43
+ set -euo pipefail
44
+
45
+ case " $1 " in
46
+ " license" )
47
+ add_license
48
+ ;;
49
+ * )
50
+ echo " Unknown fixture: $1 "
51
+ exit 1
52
+ ;;
53
+ esac
54
+ }
55
+
56
+ main " $@ "
You can’t perform that action at this time.
0 commit comments