leafsummer
8/14/2015 - 8:51 AM

front web deploy script

front web deploy script

#!/bin/bash
#celery web deploy

####################错误敏感####################
set -e

####################参数个数校验、获取入参####################
if [ $# != 1 ] ; then
    echo -e "arguments number error"
    exit 1; 
fi
API_ADDRESS=$1

####################svn操作####################

NGINX_CONF=/opt/disk2/var/serverconfig/www-nginx.conf
SVN_USERNAME=""
SVN_PASSWORD=""
CELERY_WEB_SVN=https://192.168.5.246/svn/cloud/trunk/html/management_web

WEB_PROJECT_DIR=/opt/disk2/var/www


####################配置文件修改,使用sed操作####################
sed -i -e "/uwsgi_pass\s\+127.0.0.1:9001;/d" $NGINX_CONF
sed -i -e "/include\s\+uwsgi_params;/d" $NGINX_CONF
sed -i -e "/location ^~ \/choi_wan_api\//,+6d" $NGINX_CONF
sed -i -e "/location\s\+\/media/i location ^~ /choi_wan_api/ {\n      proxy_pass http://$API_ADDRESS:80;\n      proxy_set_header Host \$host;\n      proxy_set_header X-Real-IP \$remote_addr;\n      proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\n      proxy_redirect off;\n}" $NGINX_CONF

echo "change config successfully"

rm -rf $WEB_PROJECT_DIR

svn co $CELERY_WEB_SVN $WEB_PROJECT_DIR --username $SVN_USERNAME --password $SVN_PASSWORD --no-auth-cache  --quiet <<EOF
t
EOF

####################启动服务####################
/etc/init.d/nginx restart
echo "choi-wan web start successfully"