add hook, fix demo script

master
Cold-Egg 5 years ago
parent bcf12dbf18
commit 3a1aa4c6fb

@ -1,6 +1,7 @@
#!/usr/bin/env bash
DOMAIN=''
TYPE=0
CONT_NAME='litespeed'
help_message(){
echo 'Command [your_domain]'
@ -54,10 +55,15 @@ lecertapply(){
fi
}
certbothook(){
docker-compose exec ${CONT_NAME} su -s /bin/bash -c "certhookctl.sh"
}
main(){
www_domain ${1}
domain_verify
lecertapply ${DOMAIN}
certbothook
bash bin/webadmin.sh -r
}

@ -71,7 +71,7 @@ set_vh_docroot(){
if [ "${VHNAME}" != '' ]; then
VH_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}"
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
VH_ROOT="${DEFAULT_VH_ROOT}/${1}"
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

@ -5,7 +5,6 @@ APP_NAME='wordpress'
DEMO_PATH="/var/www/${DEMO_VH}"
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'
}
@ -16,17 +15,27 @@ check_input(){
fi
}
run_database(){
bash bin/database.sh -domain ${DEMO_VH} -user ${MYSQL_USER} -password ${MYSQL_PASSWORD} -database ${MYSQL_DATABASE}
store_credential(){
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(){
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(){
run_database
store_credential ${DEMO_VH}
app_download ${APP_NAME} ${DOMAIN}
}

@ -21,6 +21,8 @@ RUN apt-get install -y software-properties-common && \
apt-get update && \
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
ADD conf /usr/local/lsws/conf
RUN chown 999:999 /usr/local/lsws/conf -R

Loading…
Cancel
Save