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