rm 1.5.10, use official db, update download sh

This commit is contained in:
Cold-Egg
2020-01-02 16:21:17 -05:00
parent 56d8d35387
commit f88309f31e
20 changed files with 51 additions and 1225 deletions
+39
View File
@@ -5,6 +5,7 @@ APP_NAME=''
DOMAIN=''
WWW_UID=''
WWW_GID=''
PUB_IP=$(curl http://checkip.amazonaws.com)
help_message(){
echo 'Command [-app app_name] [-domain domain_name]'
@@ -18,6 +19,14 @@ check_input(){
fi
}
linechange(){
LINENUM=$(grep -n "${1}" ${2} | cut -d: -f 1)
if [ -n "${LINENUM}" ] && [ "${LINENUM}" -eq "${LINENUM}" ] 2>/dev/null; then
sed -i "${LINENUM}d" ${2}
sed -i "${LINENUM}i${3}" ${2}
fi
}
get_owner(){
WWW_UID=$(stat -c "%u" ${DEFAULT_VH_ROOT}/${1})
WWW_GID=$(stat -c "%g" ${DEFAULT_VH_ROOT}/${1})
@@ -28,6 +37,16 @@ get_owner(){
fi
}
get_db_pass(){
if [ ${VH_DOC_ROOT}/.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 '"')
else
echo 'DB_PASS can not locate!'
fi
}
set_vh_docroot(){
if [ -d ${DEFAULT_VH_ROOT}/${1}/html ]; then
VH_DOC_ROOT="${DEFAULT_VH_ROOT}/${1}/html"
@@ -54,6 +73,25 @@ check_sql_native(){
done
}
preinstall_wordpress(){
get_db_pass
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}');"
linechange 'DB_PASSWORD' ${VH_DOC_ROOT}/wp-config.php "${NEWDBPWD}"
NEWDBPWD="define('DB_USER', '${SQL_USER}');"
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}"
elif [ -f ${VH_DOC_ROOT}/wp-config.php ]; then
echo "${VH_DOC_ROOT}/wp-config.php already exist, exit !"
exit 1
else
echo 'Skip!'
exit 2
fi
}
app_wordpress_dl(){
if [ ! -f "${VH_DOC_ROOT}/wp-config.php" ] && [ ! -f "${VH_DOC_ROOT}/wp-config-sample.php" ]; then
wp core download \
@@ -72,6 +110,7 @@ main(){
if [ "${APP_NAME}" = 'wordpress' ] || [ "${APP_NAME}" = 'wp' ]; then
check_sql_native
app_wordpress_dl
preinstall_wordpress
exit 0
else
echo "APP: ${APP_NAME} not support, exit!"