You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

5 years ago
#!/usr/bin/env bash
source .env
DEMO_VH='localhost'
APP_NAME='wordpress'
5 years ago
CONT_NAME='litespeed'
5 years ago
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
}
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
5 years ago
}
app_download(){
5 years ago
docker-compose exec ${CONT_NAME} su -c "appinstallctl.sh -app ${1} -domain ${2} -vhname ${DEMO_VH}"
5 years ago
}
lsws_restart(){
docker-compose exec ${CONT_NAME} su -c '/usr/local/lsws/bin/lswsctrl restart >/dev/null'
}
5 years ago
main(){
store_credential ${DEMO_VH}
5 years ago
app_download ${APP_NAME} ${DOMAIN}
lsws_restart
5 years ago
}
while [ ! -z "${1}" ]; do
case ${1} in
-[hH] | -help | --help)
help_message
;;
*)
help_message
;;
esac
shift
done
main