Files
ols-docker-env/bin/demosite.sh
T

59 lines
1.3 KiB
Bash
Raw Normal View History

2020-01-08 16:49:52 -05:00
#!/usr/bin/env bash
source .env
DEMO_VH='localhost'
APP_NAME='wordpress'
2020-01-17 16:09:55 -05:00
CONT_NAME='litespeed'
2020-01-08 16:49:52 -05:00
DEMO_PATH="/var/www/${DEMO_VH}"
help_message(){
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
}
2020-01-15 15:34:04 -05:00
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
2020-01-08 16:49:52 -05:00
}
app_download(){
2020-01-17 16:09:55 -05:00
docker-compose exec ${CONT_NAME} su -c "appinstallctl.sh -app ${1} -domain ${2} -vhname ${DEMO_VH}"
2020-01-08 16:49:52 -05:00
}
2020-02-12 16:09:02 -05:00
lsws_restart(){
docker-compose exec ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
2020-01-08 16:49:52 -05:00
main(){
2020-01-15 15:34:04 -05:00
store_credential ${DEMO_VH}
2020-01-08 16:49:52 -05:00
app_download ${APP_NAME} ${DOMAIN}
2020-02-12 16:09:02 -05:00
lsws_restart
2020-01-08 16:49:52 -05:00
}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
*)
help_message
;;
esac
shift
done
main