haproxy.sh 816 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env sh
  2. #Here is a script to deploy cert to haproxy server.
  3. #returns 0 means success, otherwise error.
  4. ######## Public functions #####################
  5. #domain keyfile certfile cafile fullchain
  6. haproxy_deploy() {
  7. _cdomain="$1"
  8. _ckey="$2"
  9. _ccert="$3"
  10. _cca="$4"
  11. _cfullchain="$5"
  12. _debug _cdomain "$_cdomain"
  13. _debug _ckey "$_ckey"
  14. _debug _ccert "$_ccert"
  15. _debug _cca "$_cca"
  16. _debug _cfullchain "$_cfullchain"
  17. # combine the key and fullchain into a single pem and install
  18. _savedomainconf DEPLOY_HAPROXY_PEM_PATH "$DEPLOY_HAPROXY_PEM_PATH"
  19. _pem_full_path="$DEPLOY_HAPROXY_PEM_PATH/$_cdomain.pem"
  20. _info "Full path to PEM $_pem_full_path"
  21. cat "$_cfullchain" "$_ckey" > "$_pem_full_path"
  22. chmod 600 "$_pem_full_path"
  23. _info "Certificate successfully deployed"
  24. return 0
  25. }