#!bin/sh
#vps wordpress一键重新安装脚本
#global setting
USERNAME="root" #数据库用户名
PASSWORD="ksharpdabu.info" #数据库密码
DBNAME="wordpress" #要导入的数据库名
BACKUPSQL="/home/ksharpdabu.sql" #备份的sql文件绝对路径
OLD_WP-CONFIG="/home/wp-config.php" #以前保存到wp-config.php文件的绝对路径
#setting end!!
WEBROOT="/home/wwwroot" #网站根目录http://www.dabu.info/?p=4329
echo "###################################################################\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "please backup your website data when you run this shell script!!!!\n"
echo "###################################################################\n"
get_char() #这一段的代码其实的功能就是让用户输入任意键以继续执行脚本,是常用的代码段
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "ress any key to start..."
char=`get_char`
create_db="create database IF NOT EXISTS ${DBNAME}"
mysql -u${USERNAME} -p${PASSWORD} -e "${create_db}" #创建名为wordpress的数据库,如果不存在http://www.dabu.info/?p=4329
wget -c http:#cn.wordpress.org/wordpress-3.7.1-zh_CN.zip #下载wordpress网站程序
unzip wordpress-3.7.1-zh_CN.zip #解压wordpress程序
cd wordpress #切换到解压后的wordpress目录
cp ./* ${WEBROOT} #将网站程序复制到网站根目录
\cp ${OLD_WP-CONFIG} ${WEBROOT} #将原先的wordpress的配置文件wp-config.php放到网站根目录
mysql -u${USERNAME} -p${PASSWORD} ${DBNAME} /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "ress any key to start..."
char=`get_char`
create_db="create database IF NOT EXISTS ${DBNAME}"
mysql -u${USERNAME} -p${PASSWORD} -e "${create_db}" #创建名为wordpress的数据库,如果不存在http://www.dabu.info/?p=4329