mirror of
https://github.com/10h30/ols-docker-env.git
synced 2026-05-12 15:21:24 +09:00
add hook, fix demo script
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
DOMAIN=''
|
DOMAIN=''
|
||||||
TYPE=0
|
TYPE=0
|
||||||
|
CONT_NAME='litespeed'
|
||||||
|
|
||||||
help_message(){
|
help_message(){
|
||||||
echo 'Command [your_domain]'
|
echo 'Command [your_domain]'
|
||||||
@@ -54,10 +55,15 @@ lecertapply(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
certbothook(){
|
||||||
|
docker-compose exec ${CONT_NAME} su -s /bin/bash -c "certhookctl.sh"
|
||||||
|
}
|
||||||
|
|
||||||
main(){
|
main(){
|
||||||
www_domain ${1}
|
www_domain ${1}
|
||||||
domain_verify
|
domain_verify
|
||||||
lecertapply ${DOMAIN}
|
lecertapply ${DOMAIN}
|
||||||
|
certbothook
|
||||||
bash bin/webadmin.sh -r
|
bash bin/webadmin.sh -r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ set_vh_docroot(){
|
|||||||
if [ "${VHNAME}" != '' ]; then
|
if [ "${VHNAME}" != '' ]; then
|
||||||
VH_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}"
|
VH_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}"
|
||||||
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}/html"
|
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}/html"
|
||||||
WP_CONS_TCONF="${VH_DOC_ROOT}/wp-content/plugins/litespeed-cache/data/const.default.ini"
|
WP_CONST_CONF="${VH_DOC_ROOT}/wp-content/plugins/litespeed-cache/data/const.default.ini"
|
||||||
elif [ -d ${DEFAULT_VH_ROOT}/${1}/html ]; then
|
elif [ -d ${DEFAULT_VH_ROOT}/${1}/html ]; then
|
||||||
VH_ROOT="${DEFAULT_VH_ROOT}/${1}"
|
VH_ROOT="${DEFAULT_VH_ROOT}/${1}"
|
||||||
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${1}/html"
|
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${1}/html"
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
BOTCRON='/etc/cron.d/certbot'
|
||||||
|
|
||||||
|
certbothook(){
|
||||||
|
grep 'lswsctrl restart' ${BOTCRON} >/dev/null
|
||||||
|
if [ ${?} = 1 ]; then
|
||||||
|
echo 'Add LSWS hook to certbot cronjob.'
|
||||||
|
sed -i 's/0.*renew/& --deploy-hook "\/usr\/local\/lsws\/bin\/lswsctrl restart"/g' ${BOTCRON}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
certbothook
|
||||||
+15
-6
@@ -5,7 +5,6 @@ APP_NAME='wordpress'
|
|||||||
DEMO_PATH="/var/www/${DEMO_VH}"
|
DEMO_PATH="/var/www/${DEMO_VH}"
|
||||||
|
|
||||||
help_message(){
|
help_message(){
|
||||||
echo 'Command [-domain]'
|
|
||||||
echo 'Script will get database password and wordpress password from .env file and install the demo wordpress site for you'
|
echo 'Script will get database password and wordpress password from .env file and install the demo wordpress site for you'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,17 +15,27 @@ check_input(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
run_database(){
|
store_credential(){
|
||||||
bash bin/database.sh -domain ${DEMO_VH} -user ${MYSQL_USER} -password ${MYSQL_PASSWORD} -database ${MYSQL_DATABASE}
|
if [ -d "./sites/${1}" ]; then
|
||||||
|
if [ -f ./sites/${1}/.db_pass ]; then
|
||||||
|
mv ./sites/${1}/.db_pass ./sites/${1}/.db_pass.bk
|
||||||
|
fi
|
||||||
|
cat > "./sites/${1}/.db_pass" << EOT
|
||||||
|
"Database":"${MYSQL_DATABASE}"
|
||||||
|
"Username":"${MYSQL_USER}"
|
||||||
|
"Password":"$(echo ${MYSQL_PASSWORD} | tr -d "'")"
|
||||||
|
EOT
|
||||||
|
else
|
||||||
|
echo "./sites/${1} not found, abort credential store!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app_download(){
|
app_download(){
|
||||||
docker-compose exec litespeed su -c "appinstallctl.sh -app ${1} -domain ${2} -vhname localhost"
|
docker-compose exec litespeed su -c "appinstallctl.sh -app ${1} -domain ${2} -vhname ${DEMO_VH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
main(){
|
main(){
|
||||||
run_database
|
store_credential ${DEMO_VH}
|
||||||
app_download ${APP_NAME} ${DOMAIN}
|
app_download ${APP_NAME} ${DOMAIN}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ RUN apt-get install -y software-properties-common && \
|
|||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y certbot python-certbot-apache
|
apt-get install -y certbot python-certbot-apache
|
||||||
|
|
||||||
|
RUN sed 's/0.*.certbot/& --deploy-hook "\/usr\/local\/lsws\/bin\/lswsctrl restart"/g' /etc/cron.d/certbot
|
||||||
|
|
||||||
RUN rm -rf /usr/local/lsws/conf
|
RUN rm -rf /usr/local/lsws/conf
|
||||||
ADD conf /usr/local/lsws/conf
|
ADD conf /usr/local/lsws/conf
|
||||||
RUN chown 999:999 /usr/local/lsws/conf -R
|
RUN chown 999:999 /usr/local/lsws/conf -R
|
||||||
|
|||||||
Reference in New Issue
Block a user