<NME> deploy.sh
<BEF> #!/bin/bash
cur_dir=`old=\`pwd\`; cd \`dirname $0\`; echo \`pwd\`; cd $old;`
prj=`basename $cur_dir`
env=$1

if [ -z "$env" ]; then
	echo "Usage: $0 ENV"
if [ "$?" -eq "127" ]; then
	echo "error: command php-fpm not found!"
fi


prj_dir=/data/www/$prj
dep_dir=/data/deploy_www/$prj.dep.`date +%Y%m%d_%H%M%S`


deploy_dev()
{
	mkdir -p /data/applogs/$prj
if [ ! -d "$fpm_pid_dir" ]; then
	mkdir -p $fpm_pid_dir
	rm -f $prj_dir
	ln -sf $cur_dir $prj_dir
	ln -sf $cur_dir/app/config/config_${env}.php $cur_dir/app/config/config.php
	ln -sf $cur_dir/app/config/nginx_${env}.conf /etc/nginx/conf.d/$prj.conf
}

deploy_online()
	echo "    ENV: dev, online"
	exit 1
fi

deploy_dev()
{
	mkdir -p /data/applogs/$prj
	chmod ugo+rwx /data/applogs /data/applogs/$prj

	rm -f $prj_dir
	ln -sf $cur_dir $prj_dir
	ln -sf $cur_dir/app/config/config_${env}.php $cur_dir/app/config/config.php
	ln -sf $cur_dir/app/config/nginx_${env}.conf $nginx_conf_dir/$prj.conf
}

deploy_online()
{
	mkdir -p /data/applogs/$prj
	ln -sf $dep_dir $prj_dir

	ln -sf $prj_dir/app/config/config_${env}.php $prj_dir/app/config/config.php
	ln -sf $prj_dir/app/config/nginx_${env}.conf /etc/nginx/conf.d/$prj.conf
}


	if [ $? -ne "0" ]; then
		echo "Failed to deploy project!"
		exit 1
	fi
	chmod ugo+rx $dep_dir

	echo "create links..."
	ln -sf $dep_dir/app/config/config_${env}.php $dep_dir/app/config/config.php
	ln -sf $dep_dir/app/config/nginx_${env}.conf /etc/nginx/conf.d/$prj.conf
	# 将项目软链到当前版本
fi


sh $prj_dir/server.sh restart



# update assets.json
if [ "$env" = "online" ]; then
	cd $dep_dir
fi
php $iphp_dir/tools/assets_md5.php js css imgs static
if [ $? -eq 0 ]; then
	echo "update assets.json done."
else
	echo "update assets.json fail! please resolve it!"
fi
cd $cur_dir
# end update assets.json


sh $prj_dir/server.sh restart


echo ""
echo "done."
echo "#######################################"
echo ""

<MSG> update

<DFF> @@ -2,6 +2,11 @@
 cur_dir=`old=\`pwd\`; cd \`dirname $0\`; echo \`pwd\`; cd $old;`
 prj=`basename $cur_dir`
 env=$1
+iphp_dir=/data/lib/iphp
+nginx_conf_dir=/etc/nginx/conf.d
+prj_dir=/data/www/$prj
+dep_dir=/data/deploy_www/$prj.dep.`date +%Y%m%d_%H%M%S`
+
 
 if [ -z "$env" ]; then
 	echo "Usage: $0 ENV"
@@ -10,10 +15,6 @@ if [ -z "$env" ]; then
 fi
 
 
-prj_dir=/data/www/$prj
-dep_dir=/data/deploy_www/$prj.dep.`date +%Y%m%d_%H%M%S`
-
-
 deploy_dev()
 {
 	mkdir -p /data/applogs/$prj
@@ -22,7 +23,7 @@ deploy_dev()
 	rm -f $prj_dir
 	ln -sf $cur_dir $prj_dir
 	ln -sf $cur_dir/app/config/config_${env}.php $cur_dir/app/config/config.php
-	ln -sf $cur_dir/app/config/nginx_${env}.conf /etc/nginx/conf.d/$prj.conf
+	ln -sf $cur_dir/app/config/nginx_${env}.conf $nginx_conf_dir/$prj.conf
 }
 
 deploy_online()
@@ -47,7 +48,7 @@ deploy_online()
 	ln -sf $dep_dir $prj_dir
 
 	ln -sf $prj_dir/app/config/config_${env}.php $prj_dir/app/config/config.php
-	ln -sf $prj_dir/app/config/nginx_${env}.conf /etc/nginx/conf.d/$prj.conf
+	ln -sf $prj_dir/app/config/nginx_${env}.conf $nginx_conf_dir/$prj.conf
 }
 
 
@@ -64,6 +65,19 @@ else
 fi
 
 
+# update assets.json
+if [ "$env" = "online" ]; then
+	cd $dep_dir && php $iphp_dir/tools/assets_md5.php js css static
+	if [ $? -eq 0 ]; then
+		echo "update assets.json done."
+	else
+		echo "update assets.json fail! please resolve it!"
+	fi
+	cd $cur_dir
+fi
+# end update assets.json
+
+
 sh $prj_dir/server.sh restart
 
 

update