#!/bin/bash
#功能描述:
#1、一键升级wdcp为v3.2.2
#2、自动导入原v2.5的站点信息
#3、备份原v2.5配置文件到/home/wddata2,若需还原v2.5
# 恢复备份,然后将现在wddata改名,将/home/wddata2改名为/home/wddata
#
#注意事项:
#1、升级时,请暂停网站,以免数据不同步
#2、升级后,所有FTP用户都需要重新设置密码,也可在使用时再重设。
#3、之前部署ssl,若证书文件存放根分区,请注意备份证书文件。
#
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
serviceall(){
service nginxd $1
service httpd $1
service mysqld $1
service memcached $1
service pureftpd $1
}
install_ftp(){
service pureftpd stop
wget -c http://dl.wdlinux.cn/files/ftp/pure-ftpd-1.0.42.tar.gz
tar zxvf pure-ftpd-1.0.42.tar.gz
cd pure-ftpd-1.0.42
./configure --prefix=/www/wdlinux/pureftpd-1.0.42 \
--with-puredb \
--with-quotas \
--with-cookie \
--with-virtualhosts \
--with-virtualchroot \
--with-diraliases \
--with-sysquotas \
--with-ratios \
--with-altlog \
--with-paranoidmsg \
--with-shadow \
--with-welcomemsg \
--with-throttling \
--with-uploadscript \
--with-rfc2640 \
--with-ftpwho \
--with-language=simplified-chinese
make
make install
rm -f /www/wdlinux/pureftpd
ln -sf /www/wdlinux/pureftpd-1.0.42 /www/wdlinux/pureftpd
cp configuration-file/pure-config.pl /www/wdlinux/pureftpd/sbin/
chmod 755 /www/wdlinux/pureftpd/sbin/pure-config.pl
mkdir /www/wdlinux/pureftpd/etc -p
touch /www/wdlinux/pureftpd/etc/{pureftpd.passwd,pureftpd.pdb}
rm -f /www/wdlinux/etc/pure-ftpd.conf
wget -c http://www.wdlinux.cn/conf/ftp/pure-ftpd.conf -O /www/wdlinux/etc/pure-ftpd.conf
}
update_wdcp(){
ind="/www/wdlinux/wdcp"
if [ -f $ind/data/db.inc.php ];then
if [ -d /www/wdlinux/wdcp/phpmyadmin ];then
cp -pR /www/wdlinux/wdcp/phpmyadmin /www/web/default/pma_*****
fi
sed -i 's#/wdcp#/wdcp2#' /www/wdlinux/wdapache/conf/httpd.conf
service wdapache stop
mv $ind /www/wdlinux/wdcp2
wport=`grep "Listen " /www/wdlinux/wdapache/conf/httpd.conf|awk 'NR==4{print}'|awk '{print $2}'`
grep "$wport" /www/wdlinux/wdapache/conf/httpd.conf
if [ $? == 0 ];then
sed -i "s/$wport/8090/g" /www/wdlinux/wdapache/conf/httpd.conf
iptables -I INPUT -p tcp --dport 8090 -j ACCEPT
else
iptables -I INPUT -p tcp --dport $wport -j ACCEPT
fi
iptables-save > /etc/sysconfig/iptables
fi
if [ ! -d $ind ];then
mkdir -p $ind
fi
pushd $ind
filename="wdcp_v3.2.2_64.tar.gz"
wget -c http://dl.wdlinux.cn/files//wdcp/$filename
if [ $? == 0 ];then
tar zxvf $filename
mkdir {logs,tmp,rewrite}
ln -sf bin/wdcp_v3.2.2_64 wdcp
if [ ! -f /bin/mysql ];then
ln -s /www/wdlinux/mysql/bin/mysql /bin/mysql
fi
chown root.root bin favicon.ico html static shell conf -R
chmod 700 data conf shell bin html
ln -sf /www/wdlinux/wdcp/wdcp.sh /etc/rc.d/init.d/wdcp
chkconfig --add wdcp
chkconfig --level 35 wdcp on
pushd $ind
rm -f $filename
fi
}
wdcp_modified(){
serviceall "stop"
mv /home/wddata/ /home/wddata2
mkdir -p /home/wddata
mkdir -p /home/wddata/vhost
mkdir -p /home/wddata/wdcp
pushd /home/wddata/
mv /www/wdlinux/wdcp/etc.tar.gz ./
tar xvzf etc.tar.gz
mv /www/wdlinux/pureftpd/etc /home/wddata/etc/pureftpd_etc
ln -sf /home/wddata/etc/pureftpd_etc /www/wdlinux/pureftpd/etc
cp -pR /home/wddata2/vhost /home/wddata/vhost/apache_vhost
rm -f /www/wdlinux/apache/conf/vhost
ln -sf /home/wddata/vhost/apache_vhost /www/wdlinux/apache/conf/vhost
cp -pR /www/wdlinux/nginx/conf/vhost /home/wddata/vhost/nginx_vhost
mv /www/wdlinux/nginx/conf/vhost/ /home/wddata2/nginx_vhost
ln -sf /home/wddata/vhost/nginx_vhost /www/wdlinux/nginx/conf/vhost
rm -f /www/wdlinux/mysql/var
ln -sf /home/wddata2/var /www/wdlinux/mysql/var
rm -f /www/wdlinux/wdcp2/data
ln -sf /home/wddata2/data /www/wdlinux/wdcp2/data
mv /www/wdlinux/wdcp/conf /home/wddata/wdcp/conf
ln -sf /home/wddata/wdcp/conf /www/wdlinux/wdcp/conf
mv /www/wdlinux/wdcp/data /home/wddata/wdcp/data
ln -sf /home/wddata/wdcp/data /www/wdlinux/wdcp/data
serviceall "start"
service wdcp start
ip=`ifconfig eth0 | grep "inet addr" | awk '{ print $2}' | awk -F: '{print $2}'`
sh /www/wdlinux/wdcp/shell/mysqlrootchp.sh
cp -pR /home/wddata2/var /home/wddata/mysql_data
echo -e "\033[40;32mimport v2.5 data ...\033[40;37m"
echo
sleep 2
curl -c ./cookie_c.txt -F "username=admin" -F "passwd=wdlinux.cn" "http://${ip}:8080/login"
sleep 2
curl -b ./cookie_c.txt "http://${ip}:8080/index?act=import"
echo
sh /www/wdlinux/wdcp/shell/wdcploginchp.sh
}
main(){
bit=`getconf LONG_BIT`
if [ $bit == '32' ] ;then
echo -e "\033[1;40;31m32bit is not support!\033[0m"
exit
fi
if [ ! -d /www/wdlinux/pureftpd-1.0.42 ];then
install_ftp
fi
if [ ! -d /www/wdlinux/wdcp2 ];then
update_wdcp
fi
if [ ! -d /home/wddata2 ];then
wdcp_modified
fi
}
main
echo -e "\033[1;40;31mPlease retain the data reinstall system\033[0m"
echo
echo -e "\033[1;40;31mchown mysql.mysql -R /home/wddata/mysql_data\033[0m"
echo -e "\033[1;40;31mupdate success!\033[0m"
echo
鱼鱼
2018年8月2日 11:11
试过多次,一直升级不成功
2018-08-02 11:01:42 (1.34 MB/s) – ?.dcp_v3.2.2_64.tar.gz?.saved [4184281/4184281]
bin/wdcp_v3.2.2_64
favicon.ico
html/
html/safe/
html/safe/ssh_chp_k.htm
html/safe/iptables_add.htm
html/safe/selinux.htm
html/safe/ssh.htm
html/safe/ping.htm
html/safe/iptables.htm
html/err/
html/err/404.htm
html/layout/
html/layout/index.htm
html/mysql/
html/mysql/chgpw.htm
html/mysql/list.htm
html/mysql/set.htm
html/mysql/add.htm
html/mysql/chgrootpw.htm
html/mysql/rootpw.htm
html/ftp/
html/ftp/chpwd.htm
html/ftp/list.htm
html/ftp/add.htm
html/ftp/edit.htm
html/member/
html/member/chgpw.htm
html/member/list.htm
html/member/add.htm
html/member/edit.htm
html/admin/
html/admin/task_edit.htm
html/admin/task_logs.htm
html/admin/index.htm
html/admin/mail.htm
html/admin/task_add.htm
html/admin/task.htm
html/admin/conf.htm
html/admin/memcached.htm
html/admin/optlog.htm
html/admin/loginlog.htm
html/sys/
html/sys/traffic.htm
html/sys/resolv.htm
html/sys/netstat_mysql.htm
html/sys/process.htm
html/sys/netstat_all.htm
html/sys/netstat_web.htm
html/sys/ifconfig_add.htm
html/sys/cmd.htm
html/sys/disk.htm
html/sys/top.htm
html/sys/port.htm
html/sys/file_edit.htm
html/sys/server.htm
html/sys/netstat.htm
html/sys/service.htm
html/sys/time.htm
html/sys/mem.htm
html/sys/ifconfig.htm
html/sys/top_res.htm
html/sys/syslog.htm
html/sys/netstat_ip.htm
html/sys/syslog_view.htm
html/sys/file.htm
html/sys/netstat_state.htm
html/login.htm
html/site/
html/site/ssl.htm
html/site/php.htm
html/site/rewrite_add.htm
html/site/phps.htm
html/site/sdlist.htm
html/site/list.htm
html/site/htpasswd.htm
html/site/htpasswd_user.htm
html/site/add.htm
html/site/htpasswd_user_add.htm
html/site/adde.htm
html/site/rewrite.htm
html/site/edit.htm
html/site/cfc.htm
html/site/sdadd.htm
html/site/htpasswd_user_chp.htm
phps/
phps/vid/
phps/start.sh
static/
static/fun.js
static/Style/
static/Style/css_body.css
static/Style/css_menu.css
static/Style/css_top.css
static/jquery-1.9.1.min.js
static/jquery.min.js
static/JSFile/
static/JSFile/jquery.min.js
static/JSFile/fun_normal.js
static/img/
static/images/
static/images/bg.jpg
static/images/ico_1.gif
static/images/login_submit1.gif
static/images/top_bg_hr.jpg
static/images/mb_bg.gif
static/images/topbg.jpg
static/images/body_title_bg.gif
static/images/top_bg_hr2.jpg
static/images/menu_title_bg.jpg
static/images/body_title_right.gif
static/images/ico_3.gif
static/images/login_submit.gif
static/images/logo.jpg
static/images/boxsplit.jpg
static/images/admin_tlogo.jpg
static/images/mico_1.gif
static/images/Thumbs.db
static/images/body_title_left.gif
static/images/ico_2.gif
static/images/inputbut_bg.gif
static/images/bom.jpg
static/css/
wdcp.sh
shell/
shell/sitebackup.sh
shell/wdcploginchp.sh
shell/pureftpconfcheck.sh
shell/wdcpconfbackup.sh
shell/memres.sh
shell/ftpbackup.sh
shell/mysqlbackup.sh
shell/mysqlrootchp.sh
shell/wdcplogincip.sh
shell/updates.sh
license.txt
chown: cannot access `conf’: No such file or directory
chmod: cannot access `data’: No such file or directory
chmod: cannot access `conf’: No such file or directory
/www/wdlinux/wdcp /www/wdlinux/wdcp ~/pure-ftpd-1.0.42
Stopping nginx: [ OK ]
Gracefully shutting down php-fpm . done
Stopping httpd: [FAILED]
Shutting down MySQL. SUCCESS!
memcached: unrecognized service
Stopping pure-ftpd: [FAILED]
mv: cannot stat `/home/wddata/’: No such file or directory
/home/wddata /www/wdlinux/wdcp /www/wdlinux/wdcp ~/pure-ftpd-1.0.42
mv: cannot stat `/www/wdlinux/wdcp/etc.tar.gz’: No such file or directory
tar (child): etc.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
mv: cannot move `/www/wdlinux/pureftpd/etc’ to `/home/wddata/etc/pureftpd_etc’: No such file or directory
cp: cannot stat `/home/wddata2/vhost’: No such file or directory
rm: cannot remove `/www/wdlinux/apache/conf/vhost’: Is a directory
mv: cannot move `/www/wdlinux/nginx/conf/vhost/’ to `/home/wddata2/nginx_vhost’: No such file or directory
rm: cannot remove `/www/wdlinux/mysql/var’: Is a directory
rm: cannot remove `/www/wdlinux/wdcp2/data’: Is a directory
mv: cannot stat `/www/wdlinux/wdcp/conf’: No such file or directory
mv: cannot stat `/www/wdlinux/wdcp/data’: No such file or directory
Starting nginx: [ OK ]
Starting php-fpm Cannot load Zend Extension Manager – it was built with configuration 1.2.0, whereas running engine is API220090626,NTS
done
Starting httpd: [ OK ]
Starting MySQL. SUCCESS!
memcached: unrecognized service
Starting pure-ftpd:
Starting wdcp: [ OK ]
[ORM]register db Ping `default`, unable to open database file
must have one register DataBase alias named `default`
Repairing…
/www/wdlinux/wdcp/shell/mysqlrootchp.sh: line 11: /www/wdlinux/wdcp/conf/mrpw.conf: No such file or directory
ERROR! MySQL manager or server PID file could not be found!
Starting MySQL. SUCCESS!
New Mysql Root Password:3c9270ee
cp: cannot stat `/home/wddata2/var’: No such file or directory
import v2.5 data …
curl: (7) couldn’t connect to host
curl: (7) couldn’t connect to host
[ORM]register db Ping `default`, unable to open database file
must have one register DataBase alias named `default`
Please retain the data reinstall system
chown mysql.mysql -R /home/wddata/mysql_data
update success!
能帮忙看看哪里出问题了么??
ropon
2018年8月6日 21:25
目录结构不同
鱼鱼
2018年8月8日 11:52
看脚本有个mv: `/www/wdlinux/wdcp/etc.tar.gz的命令,但是脚本却没有打包成etc.tar.gz的命令,正常情况WDCP上也是没有etc.tar.gz这个压缩包的吧,我对了一下目录结构,应该是一样的