Skip to content

Commit 2a92d9d

Browse files
committed
chore(scripts/develop.sh): add license from env var if provided
1 parent 48a4ab0 commit 2a92d9d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scripts/develop.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ source "${SCRIPT_DIR}/lib.sh"
1414
set -euo pipefail
1515

1616
CODER_DEV_ACCESS_URL="${CODER_DEV_ACCESS_URL:-http://127.0.0.1:3000}"
17+
CODER_DEV_LICENSE="${CODER_DEV_LICENSE:-""}"
1718
DEVELOP_IN_CODER="${DEVELOP_IN_CODER:-0}"
1819
debug=0
1920
DEFAULT_PASSWORD="SomeSecurePassword!"
@@ -200,6 +201,18 @@ fatal() {
200201
echo 'Failed to create regular user. To troubleshoot, try running this command manually.'
201202
fi
202203

204+
# Add a license if one is provided and we are not operating in AGPL mode.
205+
if [ "${CODER_BUILD_AGPL:-0}" -gt "0" ]; then
206+
if [ -n "${CODER_DEV_LICENSE}" ]; then
207+
NUM_LICENSES=$("${CODER_DEV_SHIM}" licenses list -o json | jq -r '. | length')
208+
if [ "${NUM_LICENSES}" -eq "0" ]; then
209+
echo -n "${CODER_DEV_LICENSE}" | "${CODER_DEV_SHIM}" licenses add -f - || echo "ERROR: failed to add license. Try adding one manually."
210+
else
211+
echo "At least one license already exists."
212+
fi
213+
fi
214+
fi
215+
203216
# Create a new organization and add the member user to it.
204217
if [ "${multi_org}" -gt "0" ]; then
205218
another_org="second-organization"

0 commit comments

Comments
 (0)