diff --git a/bin/appinstall.sh b/bin/appinstall.sh old mode 100644 new mode 100755 diff --git a/bin/container/appinstallctl.sh b/bin/container/appinstallctl.sh old mode 100644 new mode 100755 index e0d23eb..0955dcc --- a/bin/container/appinstallctl.sh +++ b/bin/container/appinstallctl.sh @@ -11,6 +11,7 @@ PUB_IP=$(curl http://checkip.amazonaws.com) help_message(){ echo 'Command [-app app_name] [-domain domain_name]' echo 'Example: appinstallctl.sh -app wordpress -d example.com' + exit 0 } check_input(){ @@ -40,9 +41,9 @@ get_owner(){ get_db_pass(){ if [ -f ${DEFAULT_VH_ROOT}/${1}/.db_pass ]; then - SQL_DB=$(grep -i Database ${VH_DOC_ROOT}/.db_pass | awk -F ':' '{print $2}' | tr -d '"') - SQL_USER=$(grep -i Username ${VH_DOC_ROOT}/.db_pass | awk -F ':' '{print $2}' | tr -d '"') - SQL_PASS=$(grep -i Password ${VH_DOC_ROOT}/.db_pass | awk -F ':' '{print $2}' | tr -d '"') + SQL_DB=$(grep -i Database ${VH_ROOT}/.db_pass | awk -F ':' '{print $2}' | tr -d '"') + SQL_USER=$(grep -i Username ${VH_ROOT}/.db_pass | awk -F ':' '{print $2}' | tr -d '"') + SQL_PASS=$(grep -i Password ${VH_ROOT}/.db_pass | awk -F ':' '{print $2}' | tr -d '"') else echo 'DB_PASS can not locate!' fi @@ -50,8 +51,10 @@ get_db_pass(){ set_vh_docroot(){ if [ "${VHNAME}" != '' ]; then + VH_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}" VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${VHNAME}/html" elif [ -d ${DEFAULT_VH_ROOT}/${1}/html ]; then + VH_ROOT="${DEFAULT_VH_ROOT}/${1}" VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${1}/html" else echo "${DEFAULT_VH_ROOT}/${1}/html does not exist, please add domain first! Abort!" @@ -76,7 +79,11 @@ check_sql_native(){ } preinstall_wordpress(){ - get_db_pass ${DOMAIN} + if [ "${VHNAME}" != '' ]; then + get_db_pass ${VHNAME} + else + get_db_pass ${DOMAIN} + fi if [ ! -f ${VH_DOC_ROOT}/wp-config.php ] && [ -f ${VH_DOC_ROOT}/wp-config-sample.php ]; then cp ${VH_DOC_ROOT}/wp-config-sample.php ${VH_DOC_ROOT}/wp-config.php NEWDBPWD="define('DB_PASSWORD', '${SQL_PASS}');" @@ -85,6 +92,8 @@ preinstall_wordpress(){ linechange 'DB_USER' ${VH_DOC_ROOT}/wp-config.php "${NEWDBPWD}" NEWDBPWD="define('DB_NAME', '${SQL_DB}');" linechange 'DB_NAME' ${VH_DOC_ROOT}/wp-config.php "${NEWDBPWD}" + NEWDBPWD="define('DB_HOST', '${PUB_IP}');" + linechange 'DB_HOST' ${VH_DOC_ROOT}/wp-config.php "${NEWDBPWD}" elif [ -f ${VH_DOC_ROOT}/wp-config.php ]; then echo "${VH_DOC_ROOT}/wp-config.php already exist, exit !" exit 1 @@ -98,10 +107,14 @@ app_wordpress_dl(){ if [ ! -f "${VH_DOC_ROOT}/wp-config.php" ] && [ ! -f "${VH_DOC_ROOT}/wp-config-sample.php" ]; then wp core download \ --allow-root \ - --force - chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${DOMAIN} + --quiet + if [ "${VHNAME}" != '' ]; then + chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${VHNAME} + else + chown -R ${WWW_UID}:${WWW_GID} ${DEFAULT_VH_ROOT}/${DOMAIN} + fi else - echo 'wp-config*.php already exist, abort!' + echo 'wp-config*.php already exist, abort!' exit 1 fi } diff --git a/bin/database.sh b/bin/database.sh index e24a841..eb03cc0 100755 --- a/bin/database.sh +++ b/bin/database.sh @@ -57,7 +57,7 @@ store_credential(){ mv ./sites/${1}/.db_pass ./sites/${1}/.db_pass.bk fi cat > "./sites/${1}/.db_pass" << EOT -"Database":"${SQL_DB}" +"Database":"${SQL_DB}" "Username":"${SQL_USER}" "Password":"$(echo ${SQL_PASS} | tr -d "'")" EOT diff --git a/bin/demosite.sh b/bin/demosite.sh old mode 100644 new mode 100755 diff --git a/bin/setwebadmin.sh b/bin/setwebadmin.sh index f28f29c..62c8c53 100755 --- a/bin/setwebadmin.sh +++ b/bin/setwebadmin.sh @@ -1,4 +1,36 @@ #!/usr/bin/env bash -docker-compose exec litespeed su -s /bin/bash lsadm -c \ - 'echo "admin:$(/usr/local/lsws/admin/fcgi-bin/admin_php* -q $/usr/local/lsws/admin/misc/htpasswd.php '${1}')" > /usr/local/lsws/admin/conf/htpasswd'; - \ No newline at end of file + +help_message(){ + echo 'Command [PASSWORD]' + echo 'Example: setwebadmin.sh mypassword' + exit 0 +} + +check_input(){ + if [ -z "${1}" ]; then + help_message + exit 1 + fi +} + +set_web_admin(){ + docker-compose exec litespeed su -s /bin/bash lsadm -c \ + 'echo "admin:$(/usr/local/lsws/admin/fcgi-bin/admin_php* -q /usr/local/lsws/admin/misc/htpasswd.php '${1}')" > /usr/local/lsws/admin/conf/htpasswd'; +} + +main(){ + set_web_admin +} + +check_input ${1} +while [ ! -z "${1}" ]; do + case ${1} in + -[hH] | -help | --help) + help_message + ;; + *) + main + ;; + esac + shift +done \ No newline at end of file diff --git a/config/litespeed/1.6.4.lh/Dockerfile b/config/litespeed/1.6.4.lh/Dockerfile index 0fc54f8..dbb485c 100644 --- a/config/litespeed/1.6.4.lh/Dockerfile +++ b/config/litespeed/1.6.4.lh/Dockerfile @@ -27,6 +27,6 @@ RUN chown 999:999 /usr/local/lsws/conf -R COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] -WORKDIR /var/www/html/ +WORKDIR /var/www/vhosts/ CMD ["/usr/local/lsws/bin/openlitespeed","-n"] diff --git a/config/litespeed/1.6.4/Dockerfile b/config/litespeed/1.6.4/Dockerfile index 5c2344b..28f94b3 100644 --- a/config/litespeed/1.6.4/Dockerfile +++ b/config/litespeed/1.6.4/Dockerfile @@ -22,6 +22,6 @@ RUN chown 999:999 /usr/local/lsws/conf -R COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] -WORKDIR /var/www/html/ +WORKDIR /var/www/vhosts/ CMD ["/usr/local/lsws/bin/openlitespeed","-n"]