From 52a75d34b3cddc74a6c67ed556bb71ff2a6a08ac Mon Sep 17 00:00:00 2001 From: zeldaroot Date: Sat, 25 Apr 2020 03:18:55 +0300 Subject: [PATCH] Added multi subdomain --- cinemapress.sh | 22 ++++++++++--------- lib/CP_cron.js | 11 +++++++--- .../default/views/admin/includes/footer.ejs | 12 +++++----- themes/default/views/admin/main.ejs | 4 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/cinemapress.sh b/cinemapress.sh index 8be5520..780ac02 100644 --- a/cinemapress.sh +++ b/cinemapress.sh @@ -811,6 +811,7 @@ ip_install() { LOCAL_DOMAIN_=`echo ${LOCAL_DOMAIN} | sed -r "s/[^A-Za-z0-9]/_/g"` LOCAL_CLOUDFLARE_EMAIL=${2:-${CLOUDFLARE_EMAIL}} LOCAL_CLOUDFLARE_API_KEY=${3:-${CLOUDFLARE_API_KEY}} + if [ "${4}" ]; then LOCAL_SUBDOMAIN="$(echo "${4}" | sed -r "s/[^A-Za-z0-9]//g")."; fi echo "${PRC_}% https" >>/var/log/docker_log_"$(date '+%d_%m_%Y')".log @@ -839,17 +840,18 @@ ip_install() { --email "support@${LOCAL_DOMAIN}" \ --non-interactive \ --agree-tos \ - -d "${LOCAL_DOMAIN}" \ - -d "*.${LOCAL_DOMAIN}" \ + -d "${LOCAL_SUBDOMAIN}${LOCAL_DOMAIN}" \ + -d "*.${LOCAL_SUBDOMAIN}${LOCAL_DOMAIN}" \ --server https://acme-v02.api.letsencrypt.org/directory \ >>/var/log/https_"$(date '+%d_%m_%Y')".log 2>&1 sleep 15 - if [ -d "${NGX}/ssl.d/live/${LOCAL_DOMAIN}/" ]; then - openssl dhparam -out "${NGX}/ssl.d/live/${LOCAL_DOMAIN}/dhparam.pem" 2048 \ + if [ -d "${NGX}/ssl.d/live/${LOCAL_SUBDOMAIN}${LOCAL_DOMAIN}/" ]; then + openssl dhparam -out "${NGX}/ssl.d/live/${LOCAL_SUBDOMAIN}${LOCAL_DOMAIN}/dhparam.pem" 2048 \ >>/var/log/https_"$(date '+%d_%m_%Y')".log 2>&1 - sed -Ei "s/self-signed/live/g" "${NGX}/ssl.d/default.conf" + sed -Ei "s~/self-signed/~/live/~g" "${NGX}/ssl.d/default.conf" + sed -Ei "s~live/${LOCAL_DOMAIN}~live/${LOCAL_SUBDOMAIN}${LOCAL_DOMAIN}~g" "${NGX}/ssl.d/default.conf" sed -Ei "s/#ssl //g" "${NGX}/conf.d/default.conf" sed -Ei "s/\"protocol\":\s*\"http:/\"protocol\":\"https:/" \ "/home/${LOCAL_DOMAIN}/config/production/config.js" @@ -2134,12 +2136,12 @@ while [ "${WHILE}" -lt "2" ]; do exit 0 ;; "h"|"https"|6 ) - read_domain ${2} + read_domain "${2}" sh_not - read_cloudflare_email ${3} - read_cloudflare_api_key ${4} - _s ${4} - 6_https ${2} ${3} ${4} + read_cloudflare_email "${3}" + read_cloudflare_api_key "${4}" + _s "${4}" + 6_https "${2}" "${3}" "${4}" "${5}" post_commands exit 0 ;; diff --git a/lib/CP_cron.js b/lib/CP_cron.js index ee7a86f..39eb84b 100644 --- a/lib/CP_cron.js +++ b/lib/CP_cron.js @@ -858,8 +858,11 @@ if (config.botdomain && hour === 5) { } } if (danger) { - var num = parseInt(config.botdomain.replace(/[^0-9]/g, '') || '0') + 1; - config.botdomain = config.botdomain + num; + var words = config.botdomain.split('.').filter(Boolean); + + var num = parseInt(words[0].replace(/[^0-9]/g, '') || '0') + 1; + words[0] = words[0] + num; + config.botdomain = words.join('.') + '.'; CP_save.save(config, 'config', function(err) { if (err) console.log('[CP_save.save]', err); @@ -1656,7 +1659,9 @@ function dayToLetter() { .reverse() .join(''); } - return result + '.'; + var words = config.subdomain.split('.').filter(Boolean); + words[0] = result; + return words.join('.') + '.'; } /** diff --git a/themes/default/views/admin/includes/footer.ejs b/themes/default/views/admin/includes/footer.ejs index 61e9a77..32c6412 100644 --- a/themes/default/views/admin/includes/footer.ejs +++ b/themes/default/views/admin/includes/footer.ejs @@ -720,9 +720,9 @@ } if (data.config && data.config.subdomain) { - data.config.subdomain = data.config.subdomain.replace(/\./g, '') + '.'; - if (data.config.subdomain === 'www.' || data.config.subdomain === 'tv.' || data.config.subdomain === 'm.' || data.config.subdomain === 'app.') { - alert('NOT «m.», «tv.», «www.», «app.»!'); + data.config.subdomain = data.config.subdomain.replace(/\.$/g, '') + '.'; + if (data.config.subdomain === 'www.' || data.config.subdomain === 'tv.' || data.config.subdomain === 'm.' || data.config.subdomain === 'app.' || data.config.subdomain === 'ftp.') { + alert('NOT «m.», «tv.», «www.», «app.», «ftp.»!'); self.innerHTML = '  <%= __('Сохранить изменения') %>'; self.addEventListener('click', saveData); return; @@ -730,9 +730,9 @@ } if (data.config && data.config.botdomain) { - data.config.botdomain = data.config.botdomain.replace(/\./g, '') + '.'; - if (data.config.botdomain === 'www.' || data.config.botdomain === 'tv.' || data.config.botdomain === 'm.') { - alert('NOT «m.», «tv.», «www.»!'); + data.config.botdomain = data.config.botdomain.replace(/\.$/g, '') + '.'; + if (data.config.botdomain === 'www.' || data.config.botdomain === 'tv.' || data.config.botdomain === 'm.' || data.config.botdomain === 'app.' || data.config.botdomain === 'ftp.') { + alert('NOT «m.», «tv.», «www.», «app.», «ftp.»!'); self.innerHTML = '  <%= __('Сохранить изменения') %>'; self.addEventListener('click', saveData); return; diff --git a/themes/default/views/admin/main.ejs b/themes/default/views/admin/main.ejs index 0c4fd33..9ac5ba0 100644 --- a/themes/default/views/admin/main.ejs +++ b/themes/default/views/admin/main.ejs @@ -112,7 +112,7 @@
@@ -132,7 +132,7 @@
<%= __('Поддомен для ботов') %>: .<%= config.domain %>