#!/bin/bash
# nginx update scripts
# url http://pp.gy
# author pp.gy

if [ ! $1 ];then
	ver="1.2.3"
else
	ver=$1
fi

service nginxd stop

cd /tmp
wget -c http://pp.gy/i386/nginx-$ver-1.el5.ngx.i386.rpm
[ $? != 0 ] && echo "down err" && exit
rpm -ivh nginx-$ver-1.el5.ngx.i386.rpm
mv /www/wdlinux/nginx-$ver/conf/nginx.conf /www/wdlinux/nginx-$ver/conf/nginx.conf.default
cp -pR /www/wdlinux/nginx/conf/* /www/wdlinux/nginx-$ver/conf/
service nginxd stop
rm -f /www/wdlinux/nginx
rm -f /www/wdlinux/nginx-$ver/conf/nginx.conf
ln -sf /www/wdlinux/nginx-$ver /www/wdlinux/nginx

yum -y install net-snmp-devel
wget -c http://pp.gy/i386/php-5.4.6-1.el5.ngx.i386.rpm
rpm -ivh --force --nodeps php-5.4.6-1.el5.ngx.i386.rpm

wget -c http://pp.gy/i386/nginx.conf
cp nginx.conf /www/wdlinux/nginx-$ver/conf

wget -c http://pp.gy/i386/php-fpm
rm -f /www/wdlinux/init.d/php-fpm
cp php-fpm /www/wdlinux/init.d/

wget -c http://pp.gy/i386/php5.ini
rm -f /www/wdlinux/php-5.4.6/etc/php.ini
cp php5.ini /www/wdlinux/php-5.4.6/etc/php.ini

wget -c http://pp.gy/i386/ZendGuardLoader.so
cp ZendGuardLoader.so /www/wdlinux/php-5.4.6/include/php/Zend/

wget -c http://pp.gy/i386/ioncube_loader_lin_5.4.so
mkdir /www/wdlinux/php-5.4.6/include/php/ioncube
cp ioncube_loader_lin_5.4.so /www/wdlinux/php-5.4.6/include/php/ioncube

wget -c http://pp.gy/i386/tz.sphp
rm -f /www/web/default/iProber2.php
cp tz.sphp /www/web/default/iProber2.php

chmod 7777 /www/wdlinux/init.d/php-fpm

service nginxd start
echo
echo "Nginx and php Update Is OK"
echo "Nginx Ver Is:$ver"
echo