git-init.sh 543 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. # sets up a pre-commit hook to ensure that vault.yaml is encrypted
  3. #
  4. # credit goes to nick busey from homelabos for this neat little trick
  5. # https://gitlab.com/NickBusey/HomelabOS/-/issues/355
  6. if [ -d .git/ ]; then
  7. rm .git/hooks/pre-commit
  8. cat <<EOT >> .git/hooks/pre-commit
  9. if ( git show :vars/vault.yaml | grep -q "\$ANSIBLE_VAULT;" ); then
  10. echo "Vault Encrypted. Safe to commit."
  11. else
  12. echo "Vault not encrypted! Run 'make encrypt' and try again."
  13. exit 1
  14. fi
  15. EOT
  16. fi
  17. chmod +x .git/hooks/pre-commit