mirror of
https://github.com/10h30/ols-docker-env.git
synced 2026-05-12 15:21:24 +09:00
cert.sh
This commit is contained in:
+6
-1
@@ -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}
|
||||
main
|
||||
+47
-2
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -27,9 +27,30 @@ lst_match_line(){
|
||||
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)
|
||||
|
||||
+9
-6
@@ -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
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ while [ ! -z "${1}" ]; do
|
||||
help_message
|
||||
;;
|
||||
*)
|
||||
main
|
||||
main ${1}
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user