forked from srvrco/getssl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpanel_cert_upload
More file actions
executable file
·31 lines (26 loc) · 860 Bytes
/
cpanel_cert_upload
File metadata and controls
executable file
·31 lines (26 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#
# a simple script for use on shared cpanel server to automatically add the
# the certificates to cpanel if the uapi function is available
# use with RELOAD_CMD="${HOME}/cpanel_cert_upload domain.com"
domain="$1"
rawurlencode() {
local string
string=$(cat "${1}")
local strlen=${#string}
local encoded=""
local pos c o
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}"
}
ecert=$( rawurlencode "${HOME}/.getssl/${domain}/${domain}.crt" )
ekey=$( rawurlencode "${HOME}/.getssl/${domain}/${domain}.key" )
echain=$( rawurlencode "${HOME}/.getssl/${domain}/chain.crt" )
uapi SSL install_ssl domain="${domain}" cert="${ecert}" key="${ekey}" cabundle="${echain}"