lib.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. REPO_ROOT=$(git rev-parse --show-toplevel)
  2. (cd $REPO_ROOT && go install ./utils/cmd/...)
  3. mkdir -p pki
  4. echo '*' >>./pki/.gitignore
  5. function cleanup() {
  6. set +e
  7. pkill -P $$
  8. if [ -f "docker-compose.yaml" ]; then
  9. docker compose down -t 1 || :
  10. docker compose rm -f || :
  11. fi
  12. }
  13. trap cleanup EXIT SIGINT
  14. function build_anubis_ko() {
  15. (
  16. cd $REPO_ROOT && npm ci && npm run assets
  17. )
  18. (
  19. cd $REPO_ROOT &&
  20. VERSION=devel ko build \
  21. --platform=all \
  22. --base-import-paths \
  23. --tags="latest" \
  24. --image-user=1000 \
  25. --image-annotation="" \
  26. --image-label="" \
  27. ./cmd/anubis \
  28. --local
  29. )
  30. }
  31. function mint_cert() {
  32. if [ "$#" -ne 1 ]; then
  33. echo "Usage: mint_cert <domain.name>"
  34. fi
  35. domainName="$1"
  36. # If the transient local TLS certificate doesn't exist, mint a new one
  37. if [ ! -f "./pki/${domainName}/cert.pem" ]; then
  38. # Subshell to contain the directory change
  39. (
  40. cd ./pki &&
  41. mkdir -p "${domainName}" &&
  42. go tool minica -domains "${domainName}" &&
  43. cd "${domainName}" &&
  44. chmod 666 *
  45. )
  46. fi
  47. }