diff --git a/bin/appinstall.sh b/bin/appinstall.sh index 2e8ab26..b00f234 100755 --- a/bin/appinstall.sh +++ b/bin/appinstall.sh @@ -19,6 +19,11 @@ app_download(){ exit 0 } +main(){ + app_download ${APP_NAME} ${DOMAIN} +} + +check_input ${1} while [ ! -z "${1}" ]; do case ${1} in -[hH] | -help | --help) @@ -39,4 +44,4 @@ while [ ! -z "${1}" ]; do shift done -app_download ${APP_NAME} ${DOMAIN} \ No newline at end of file +main \ No newline at end of file diff --git a/bin/cert.sh b/bin/cert.sh index 32ddc83..bae6c27 100755 --- a/bin/cert.sh +++ b/bin/cert.sh @@ -1,3 +1,48 @@ #!/usr/bin/env bash -docker-compose exec litespeed su -c "certbot certonly --agree-tos --register-unsafely-without-email --webroot -w /var/www/vhosts/${1}/html -d ${1} -d www.${1}" -echo OLS needs to be restarted to detect the certificates +DOMAIN='' + +help_message(){ + echo 'Command [your_domain]' + echo 'Script will get database password and wordpress password from .env file and install the demo wordpress site for you' +} + +check_input(){ + if [ -z "${1}" ]; then + help_message + exit 1 + fi +} + +strip_www(){ + CHECK_WWW=$(echo ${1} | cut -c1-4) + if [[ ${CHECK_WWW} == www. ]] ; then + DOMAIN=$(echo ${1} | cut -c 5-) + else + DOMAIN=${1} + fi +} + +lecertapply(){ + docker-compose exec litespeed su -c "certbot certonly --agree-tos --register-unsafely-without-email \ + --non-interactive --webroot -w /var/www/vhosts/${1}/html -d ${1} -d www.${1}" +} + +main(){ + strip_www ${1} + lecertapply ${DOMAIN} +} + +check_input ${1} +while [ ! -z "${1}" ]; do + case ${1} in + -[hH] | -help | --help) + help_message + ;; + *) + main ${1} + ;; + esac + shift +done + + diff --git a/bin/container/domainctl.sh b/bin/container/domainctl.sh index 7860040..8a38594 100755 --- a/bin/container/domainctl.sh +++ b/bin/container/domainctl.sh @@ -25,11 +25,32 @@ fst_match_after(){ lst_match_line(){ fst_match_after ${1} ${2} '}' LAST_LINE_NUM=$((${FIRST_LINE_NUM}+${FIRST_NUM_AFTER}-1)) -} +} + +check_input(){ + if [ -z "${1}" ]; then + help_message + exit 1 + fi +} + +check_www(){ + CHECK_WWW=$(echo ${1} | cut -c1-4) + if [[ ${CHECK_WWW} == www. ]] ; then + echo 'www domain shoudnt be passed!' + exit 1 + fi +} + +www_domain(){ + check_www ${1} + WWW_DOMAIN=$(echo www.${1}) +} add_domain(){ dot_escape ${1} DOMAIN=${ESCAPE} + www_domain ${1} check_duplicate "member.*${DOMAIN}" ${HTTPD_CONF} if [ "${CK_RESULT}" != '' ]; then echo "# It appears the domain already exist! Check the ${HTTPD_CONF} if you believe this is a mistake!" @@ -37,7 +58,7 @@ add_domain(){ else perl -0777 -p -i -e 's/(vhTemplate centralConfigLog \{[^}]+)\}*(^.*listeners.*$)/\1$2 member '${1}' { - vhDomain '${1}' + vhDomain '${1},${WWW_DOMAIN}' }/gmi' ${HTTPD_CONF} fi } @@ -56,6 +77,7 @@ del_domain(){ fi } +check_input ${1} while [ ! -z "${1}" ]; do case ${1} in -[hH] | -help | --help) @@ -69,7 +91,7 @@ while [ ! -z "${1}" ]; do ;; *) help_message - ;; + ;; esac shift done \ No newline at end of file diff --git a/bin/database.sh b/bin/database.sh index eb03cc0..e432098 100755 --- a/bin/database.sh +++ b/bin/database.sh @@ -106,6 +106,14 @@ specify_setup_main(){ store_credential ${DOMAIN} } +main(){ + if [ "${SQL_USER}" != '' ] && [ "${SQL_PASS}" != '' ] && [ "${SQL_DB}" != '' ]; then + specify_setup_main + else + auto_setup_main + fi +} + check_input ${1} while [ ! -z "${1}" ]; do case ${1} in @@ -130,9 +138,4 @@ while [ ! -z "${1}" ]; do esac shift done - -if [ "${SQL_USER}" != '' ] && [ "${SQL_PASS}" != '' ] && [ "${SQL_DB}" != '' ]; then - specify_setup_main -else - auto_setup_main -fi +main diff --git a/bin/setwebadmin.sh b/bin/setwebadmin.sh index 62c8c53..b5bb0e8 100755 --- a/bin/setwebadmin.sh +++ b/bin/setwebadmin.sh @@ -29,7 +29,7 @@ while [ ! -z "${1}" ]; do help_message ;; *) - main + main ${1} ;; esac shift diff --git a/lsws/conf/templates/ccl.conf b/lsws/conf/templates/ccl.conf index 6c9db7e..6071729 100644 --- a/lsws/conf/templates/ccl.conf +++ b/lsws/conf/templates/ccl.conf @@ -57,6 +57,7 @@ RewriteFile .htaccess vhssl { keyFile /etc/letsencrypt/live/$VH_NAME/privkey.pem certFile /etc/letsencrypt/live/$VH_NAME/fullchain.pem + certChain 1 } }