Skip to content

Commit f9a132c

Browse files
author
srvrco
committed
adding cpanel_cert_upload script
1 parent 06ea56e commit f9a132c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

other_scripts/cpanel_cert_upload

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# a simple script for use on shared cpanel server to automatically add the
4+
# the certificates to cpanel if the uapi function is available
5+
# use with RELOAD_CMD="${HOME}/cpanel_cert_upload domain.com"
6+
7+
domain="$1"
8+
9+
rawurlencode() {
10+
local string
11+
string=$(cat "${1}")
12+
local strlen=${#string}
13+
local encoded=""
14+
local pos c o
15+
16+
for (( pos=0 ; pos<strlen ; pos++ )); do
17+
c=${string:$pos:1}
18+
case "$c" in
19+
[-_.~a-zA-Z0-9] ) o="${c}" ;;
20+
* ) printf -v o '%%%02x' "'$c"
21+
esac
22+
encoded+="${o}"
23+
done
24+
echo "${encoded}"
25+
}
26+
27+
ecert=$( rawurlencode "${HOME}/.getssl/${domain}/${domain}.crt" )
28+
ekey=$( rawurlencode "${HOME}/.getssl/${domain}/${domain}.key" )
29+
echain=$( rawurlencode "${HOME}/.getssl/${domain}/chain.crt" )
30+
31+
uapi SSL install_ssl domain="${domain}" cert="${ecert}" key="${ekey}" cabundle="${echain}"

0 commit comments

Comments
 (0)