configure 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. #
  3. # configure - Configure a product
  4. #
  5. # Usage: configure --parts "app, web" --password "password" --passfile path ...
  6. #
  7. # Manages git-crypt files, submodules and parts. Defaults to --passfile /etc/farm/gpg.key
  8. #
  9. GPG_PASSFILE=/etc/farm/gpg.key
  10. PARTS="app, ui, web"
  11. while [[ $# -gt 0 ]] ; do
  12. arg="$1"
  13. case ${arg} in
  14. --passfile)
  15. GPG_PASSFILE="${2}"
  16. shift ; shift
  17. ;;
  18. --password)
  19. GPG_PASSWORD="${2}"
  20. shift ; shift
  21. ;;
  22. --parts)
  23. PARTS="${2}"
  24. shift ; shift
  25. ;;
  26. *)
  27. break
  28. ;;
  29. esac
  30. done
  31. PARTS=$(echo ${PARTS} | tr ',' ' ')
  32. #
  33. # Decrypt secrets
  34. #
  35. if [ -x ".git-crypt" -a ! -f .decrypted ] ; then
  36. echo "Decrypt secrets"
  37. if [ -z "${GPG_PASSWORD}" -a -f ${GPG_PASSFILE} ] ; then
  38. GPG_PASSWORD=$(cat ${GPG_PASSFILE})
  39. fi
  40. if [ "${GPG_PASSWORD}" != "" ] ; then
  41. gpg --pinentry-mode loopback --no-tty --passphrase "${GPG_PASSWORD}" --yes \
  42. --output .git-crypt/keys/default/0/decrypted.key \
  43. --decrypt .git-crypt/keys/default/0/*.gpg
  44. git-crypt unlock .git-crypt/keys/default/0/decrypted.key
  45. else
  46. git-crypt unlock
  47. fi
  48. if [ $? != 0 ] ; then
  49. echo "Git unlock failed"
  50. exit 1
  51. fi
  52. >.decrypted
  53. fi
  54. git submodule update --init --recursive
  55. for PART in ${PARTS}
  56. do
  57. [ ! -d ${PART} ] && continue
  58. cd ./${PART}
  59. if [ -f configure ] ; then
  60. echo -e "\nConfigure ${PART}"
  61. PART=${PART} ./configure $*
  62. fi
  63. [ $? != 0 ] && exit 2
  64. cd ..
  65. done