Skip to content

feat(scripts): add fixtures.sh to add license to dev deployment #19374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions scripts/fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,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 "$@"
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy