Browse Source

Collect Data & Install WP

old-stable
Mitesh Shah 12 years ago
parent
commit
ecd0571d70
  1. 74
      setup/config.sh
  2. 51
      setup/install-wordpress.sh

74
setup/config.sh

@ -0,0 +1,74 @@
#!/bin/bash
# Collect The Data To Make Configuration File
CONFIG=config.txt
# Remove Previous Configuration File
if [ -f config.txt ]
then
rm config.txt
# Move Previous Configuration File To Get MYSQL Settings
#mv config.txt .config.txt
fi
# Send Global Data To Configuration File
#echo "[Global]" &>> $CONFIG
#echo "Htdocs: htdocs" &>> $CONFIG
#echo "Logs: logs" &>> $CONFIG
#echo "[/Global]" &>> $CONFIG
# Get The Domain Name Information
read -p "Enter The Domain Name (without http & www): " DOMAINNAME
echo "[Domain Name]" &>> $CONFIG
echo " Domain Name: $DOMAINNAME" &>> $CONFIG
echo "[/Domain Name]" &>> $CONFIG
echo "" &>> $CONFIG
echo "" &>> $CONFIG
# Get The MySQL Username/Password
read -p "MySQL Host [localhost]: " TEMP
read -p "Enter The MySQL Username: " MYSQLUSER
read -p "Enter The MySQL Password: " MYSQLPASS
read -p "Enter The MySQL New Database Name For Wordpress: " WPDBNAME
# If User Pressed Enter Then Used localhost as MySQL Host
if [[ $TEMP = "" ]]
then
MYSQLHOST=localhost
else
MYSQLHOST=$TEMP
fi
# Send MySQL Data To Configuration File
echo "[MySQL]" &>> $CONFIG
echo " MySQL Host: $MYSQLHOST" &>> $CONFIG
echo " MySQL Username: $MYSQLUSER" &>> $CONFIG
echo " MySQL Password: $MYSQLPASS" &>> $CONFIG
echo " WP Database: $WPDBNAME" &>> $CONFIG
echo "[/MySQL]" &>> $CONFIG
echo "" &>> $CONFIG
echo "" &>> $CONFIG
# Find Out Nginx User
NGINXUSER=$(grep user /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
# Prompt User To Chnage Nginx User
# If User Press Enter Then Use Default Nginx User
read -p "Nginx User [$NGINXUSER]: " TEMP
if [[ $TEMP = "" ]]
then
NGINXUSER=$NGINXUSER
else
NGINXUSER=$TEMP
fi
# Send Ngix Data To Configuration File
echo "[Nginx]" &>> $CONFIG
echo " Nginx Username: $NGINXUSER" &>> $CONFIG
echo "[/Nginx]" &>> $CONFIG
echo "" &>> $CONFIG
echo "" &>> $CONFIG

51
setup/install-wordpress.sh

@ -0,0 +1,51 @@
#!/bin/bash
# Capture Errors
OwnError()
{
#echo $@ >&2
clear
echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai /var/log/easyengine/error.log
exit 100
}
# Collect Data From Configuration File
WORDPRESSPATH="/var/www/$(grep 'Domain Name:' config.txt | cut -d':' -f2 | cut -d' ' -f2)/htdocs"
MYSQLHOST=$(grep "MySQL Host:" config.txt | cut -d':' -f2 | cut -d' ' -f2)
MYSQLUSER=$(grep "MySQL Username:" config.txt | cut -d':' -f2 | cut -d' ' -f2)
MYSQLPASS=$(grep "MySQL Password:" config.txt | cut -d':' -f2 | cut -d' ' -f2)
WPDBNAME=$(grep "WP Database:" config.txt | cut -d':' -f2 | cut -d' ' -f2)
NGINXUSER=$(grep "Nginx Username:" config.txt | cut -d':' -f2 | cut -d' ' -f2)
#echo $WORDPRESSPATH
#echo $MYSQLHOST
#echo $MYSQLUSER
#echo $MYSQLPASS
#echo $WPDBNAME
#echo $NGINXUSER
#exit
# Cheking WordPress Path Exist
if [ ! -d $WORDPRESSPATH ]
then
echo -e "\033[31m $WORDPRESSPATH Not Exist !! \e[0m"
echo -e "\033[34m Making Directory For $WORDPRESSPATH \e[0m"
mkdir -p $WORDPRESSPATH
fi
# Install Wordpress
cd $WORDPRESSPATH
wget -c http://wordpress.org/latest.tar.gz
tar --strip-components=1 -zxvf latest.tar.gz
rm latest.tar.gz
# Creating MySQL Database For Wordpress
mysql -u $MYSQLUSER -h $MYSQLHOST -p$MYSQLPASS -e 'create databse `$WPDBNAME`'
# Grant Ownership To Nginx User
sudo chown -R $NGINXUSER:$NGINXUSER $WORDPRESSPATH
Loading…
Cancel
Save