Skip to content

Instantly share code, notes, and snippets.

@centminmod
Last active June 7, 2019 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save centminmod/a212e339daedfb14fd40fafaab1a6550 to your computer and use it in GitHub Desktop.
Save centminmod/a212e339daedfb14fd40fafaab1a6550 to your computer and use it in GitHub Desktop.
centminmod 123.09beta01 june 7, 2019 patch for letsencrypt IDN domain support in addons/acmetool.sh and centmin mod nginx vhost generation routines

This is for centmin mod 123.09beta01 code dated june 7, 2019

SSH commands to patch your 123.09beta01 local install with test IDN domain supported code

cmupdate
cd /usr/local/src/centminmod
wget -4 -O ssl-idn.patch https://gist.githubusercontent.com/centminmod/a212e339daedfb14fd40fafaab1a6550/raw/ssl-idn.patch
patch -p1 < ssl-idn.patch

then test run centmin.sh menu without running cmupdate again which will wipe the patched changes and reset to before patch state

note: if you had preveiously created domains in centminmod you need to remove them first, you would see nginx_addvhost remove logs in /root/centminlogs which has the commands to remove the domain you created first.

you can find the logs via grep filter

ls -lahrt /root/centminlogs | grep remove
cd /usr/local/src/centminmod
./centmin.sh
diff --git a/addons/acmetool.sh b/addons/acmetool.sh
index 18f3d98e..0729fcb9 100755
--- a/addons/acmetool.sh
+++ b/addons/acmetool.sh
@@ -11,7 +11,7 @@ export LC_CTYPE=en_US.UTF-8
###############################################################
# variables
###############################################################
-ACMEVER='1.0.52'
+ACMEVER='1.0.53'
DT=$(date +"%d%m%y-%H%M%S")
ACMEDEBUG='n'
ACMEDEBUG_LOG='y'
@@ -359,7 +359,7 @@ checkdate() {
check_dns() {
vhostname_dns="$1"
# if CHECKIDN = 0 then internationalized domain name which not supported by letsencrypt
- CHECKIDN=$(echo $vhostname_dns | grep '^xn--' >/dev/null 2>&1; echo $?)
+ CHECKIDN=$(echo $vhostname_dns | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
if [[ "$CHECKIDN" = '0' ]]; then
TOPLEVELCHECK=$(dig soa @8.8.8.8 $vhostname_dns | grep -v ^\; | grep SOA | awk '{print $1}' | sed 's/\.$//' | idn)
else
@@ -472,12 +472,24 @@ split_domains() {
SAN=1
DOMAIN_LIST="$(echo "$parse_domains"| sed -e 's|\s||g' | sed -e 's|,| -d |g')"
vhostname=$(echo "$parse_domains"| awk -F ',' '{print $1}')
+ # if checkidn_vhost = 0 then internationalized domain name
+ checkidn_splitvhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
+ if [[ "$checkidn_splitvhost" = '0' ]]; then
+ DOMAIN_LIST=$(echo $DOMAIN_LIST | idn)
+ vhostname=$(echo $vhostname | idn)
+ fi
DOMAIN_LISTNGX="$(echo "$(echo "$parse_domains"| sed -e 's|,| |g') www.$vhostname")"
# take only 1st entry for nginx vhost
else
SAN=0
DOMAIN_LIST="$parse_domains"
vhostname="$parse_domains"
+ # if checkidn_vhost = 0 then internationalized domain name
+ checkidn_splitvhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
+ if [[ "$checkidn_splitvhost" = '0' ]]; then
+ DOMAIN_LIST=$(echo $DOMAIN_LIST | idn)
+ vhostname=$(echo $vhostname | idn)
+ fi
fi
}
diff --git a/centmin.sh b/centmin.sh
index a88d0353..7a7d4345 100755
--- a/centmin.sh
+++ b/centmin.sh
@@ -27,7 +27,7 @@ DT=$(date +"%d%m%y-%H%M%S")
branchname='123.09beta01'
SCRIPT_MAJORVER='1.2.3'
SCRIPT_MINORVER='09'
-SCRIPT_INCREMENTVER='181'
+SCRIPT_INCREMENTVER='182'
SCRIPT_VERSIONSHORT="${branchname}"
SCRIPT_VERSION="${SCRIPT_VERSIONSHORT}.b${SCRIPT_INCREMENTVER}"
SCRIPT_DATE='31/03/2019'
diff --git a/inc/nginx_addvhost.inc b/inc/nginx_addvhost.inc
index feb9b599..c0965101 100644
--- a/inc/nginx_addvhost.inc
+++ b/inc/nginx_addvhost.inc
@@ -1,7 +1,7 @@
check_dns() {
vhostname_dns="$1"
# if CHECKIDN = 0 then internationalized domain name which not supported by letsencrypt
- CHECKIDN=$(echo $vhostname_dns | grep '^xn--' >/dev/null 2>&1; echo $?)
+ CHECKIDN=$(echo $vhostname_dns | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
if [[ "$CHECKIDN" = '0' ]]; then
TOPLEVELCHECK=$(dig soa @8.8.8.8 $vhostname_dns | grep -v ^\; | grep SOA | awk '{print $1}' | sed 's/\.$//' | idn)
else
@@ -510,6 +510,12 @@ info_notice
read -ep "Enter vhost domain name to add (without www. prefix): " vhostname
+ # if checkidn_vhost = 0 then internationalized domain name
+ checkidn_vhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
+ if [[ "$checkidn_vhost" = '0' ]]; then
+ vhostname=$(echo $vhostname | idn)
+ fi
+
if [ -d "/home/nginx/domains/$vhostname" ]; then
echo ""
cecho "-------------------------------------------------------------" $boldyellow
diff --git a/inc/wpsetup-fastcgi-cache.inc b/inc/wpsetup-fastcgi-cache.inc
index 8d23c55d..0ecbb041 100644
--- a/inc/wpsetup-fastcgi-cache.inc
+++ b/inc/wpsetup-fastcgi-cache.inc
@@ -406,6 +406,12 @@ fc_wpinfo_notice
read -ep "Enter vhost domain name you want to add (without www. prefix): " vhostname
+ # if checkidn_vhost = 0 then internationalized domain name
+ checkidn_vhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
+ if [[ "$checkidn_vhost" = '0' ]]; then
+ vhostname=$(echo $vhostname | idn)
+ fi
+
# check to make sure you don't add a domain name vhost that matches
# your server main hostname setup in server_name within main hostname
# nginx vhost at /usr/local/nginx/conf/conf.d/virtual.conf
diff --git a/inc/wpsetup.inc b/inc/wpsetup.inc
index 85ed6840..8af1d577 100644
--- a/inc/wpsetup.inc
+++ b/inc/wpsetup.inc
@@ -318,6 +318,12 @@ wpinfo_notice
read -ep "Enter vhost domain name you want to add (without www. prefix): " vhostname
+ # if checkidn_vhost = 0 then internationalized domain name
+ checkidn_vhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
+ if [[ "$checkidn_vhost" = '0' ]]; then
+ vhostname=$(echo $vhostname | idn)
+ fi
+
# check to make sure you don't add a domain name vhost that matches
# your server main hostname setup in server_name within main hostname
# nginx vhost at /usr/local/nginx/conf/conf.d/virtual.conf
diff --git a/tools/nv.sh b/tools/nv.sh
index 39f01548..9f003541 100755
--- a/tools/nv.sh
+++ b/tools/nv.sh
@@ -221,6 +221,11 @@ while getopts ":d:s:u:" opt; do
case "$opt" in
d)
vhostname=${OPTARG}
+ # if checkidn_vhost = 0 then internationalized domain name
+ checkidn_vhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
+ if [[ "$checkidn_vhost" = '0' ]]; then
+ vhostname=$(echo $vhostname | idn)
+ fi
RUN=y
;;
s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment