You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. #!/usr/bin/env sh
  2. #Here is a sample custom api script.
  3. #This file name is "myapi.sh"
  4. #So, here must be a method myapi_deploy()
  5. #Which will be called by acme.sh to deploy the cert
  6. #returns 0 means success, otherwise error.
  7. ######## Public functions #####################
  8. #domain keyfile certfile cafile fullchain
  9. strongswan_deploy() {
  10. _cdomain="$1"
  11. _ckey="$2"
  12. _ccert="$3"
  13. _cca="$4"
  14. _cfullchain="$5"
  15. _info "Using strongswan"
  16. if [ -x /usr/sbin/ipsec ]; then
  17. _ipsec=/usr/sbin/ipsec
  18. elif [ -x /usr/sbin/strongswan ]; then
  19. _ipsec=/usr/sbin/strongswan
  20. else
  21. _err "no strongswan or ipsec command is detected"
  22. return 1
  23. fi
  24. _info _ipsec "$_ipsec"
  25. _confdir=$($_ipsec --confdir)
  26. if [ $? -ne 0 ] || [ -z "$_confdir" ]; then
  27. _err "no strongswan --confdir is detected"
  28. return 1
  29. fi
  30. _info _confdir "$_confdir"
  31. _debug _cdomain "$_cdomain"
  32. _debug _ckey "$_ckey"
  33. _debug _ccert "$_ccert"
  34. _debug _cca "$_cca"
  35. _debug _cfullchain "$_cfullchain"
  36. cat "$_ckey" >"${_confdir}/ipsec.d/private/$(basename "$_ckey")"
  37. cat "$_ccert" >"${_confdir}/ipsec.d/certs/$(basename "$_ccert")"
  38. cat "$_cca" >"${_confdir}/ipsec.d/cacerts/$(basename "$_cca")"
  39. cat "$_cfullchain" >"${_confdir}/ipsec.d/cacerts/$(basename "$_cfullchain")"
  40. $_ipsec reload
  41. }