0 Star 0 Fork 39

轻舞凋零/vanilla

forked from 周晶/vanilla 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
setup-vanilal-demoapp 3.46 KB
一键复制 编辑 原始数据 按行查看 历史
iDev_周晶 提交于 2016-04-14 06:47 . update setup script
#!/bin/sh
### BEGIN ###
# Author: idevz
# Since: 2016/04/09
# Description: Setup Vanilla DemoApp named vademo
### END ###
VANILLA_VERSION=0.1.0.rc5
VANILLA_VERSION_DIR_STR=0_1_0_rc
VANILLA_APP_ROOT=/data/vanilla/vademo
VANILLA_APP_USER=idevz
VANILLA_APP_GROUP=sina
VANILLA_RUNNING_ENV='' #default '' is for production environment
TIME_MARK=`date "+%Y_%m_%d_%H_%M_%S"`
PLATFORM=`uname`
ECHO_E=" -e "
[ $PLATFORM = "Darwin" ] && ECHO_E=""
alert()
{
MSG=$1
echo $ECHO_E"\033[31m$MSG \033[0m\n"
}
init_vanilla_app()
{
VANILLA_APP_ROOT=$1
echo $ECHO_E"\033[40mBegin init Vanilla App: $VANILLA_APP_ROOT \033[0m\n"
[ -n $2 ] && VANILLA_APP_USER=$2
[ -n $3 ] && VANILLA_APP_GROUP=$3
[ -n $4 ] && APP_NAME=$4
[ -n $5 ] && VANILLA_RUNNING_ENV=$5
SERVICE_SH=$VANILLA_APP_ROOT/va-$APP_NAME-service
VANILLA_BIN=/usr/local/bin/vanilla-$VANILLA_VERSION
[ -d $VANILLA_APP_ROOT ] && mv -f $VANILLA_APP_ROOT $VANILLA_APP_ROOT".old_"$TIME_MARK
[ -x $VANILLA_BIN ] && $VANILLA_BIN new $VANILLA_APP_ROOT
if [[ $? -ne 0 ]];then
alert $VANILLA_BIN" is not exist, You shoud install vanilla first, to see './setup-framework -h' for more info."
exit 1
fi
sed "s/#user zhoujing staff/user $VANILLA_APP_USER $VANILLA_APP_GROUP/" $VANILLA_APP_ROOT/nginx_conf/va-nginx-development.conf>$VANILLA_APP_ROOT/nginx_conf/va-nginx-development.conf.tmp
sed "s/#user zhoujing staff/user $VANILLA_APP_USER $VANILLA_APP_GROUP/" $VANILLA_APP_ROOT/nginx_conf/va-nginx.conf>$VANILLA_APP_ROOT/nginx_conf/va-nginx.conf.tmp
mv -f $VANILLA_APP_ROOT/nginx_conf/va-nginx-development.conf.tmp $VANILLA_APP_ROOT/nginx_conf/va-nginx-development.conf
mv -f $VANILLA_APP_ROOT/nginx_conf/va-nginx.conf.tmp $VANILLA_APP_ROOT/nginx_conf/va-nginx.conf
chmod +x $SERVICE_SH
sudo $SERVICE_SH initconf $VANILLA_RUNNING_ENV
sudo $SERVICE_SH start $VANILLA_RUNNING_ENV
sudo $SERVICE_SH restart $VANILLA_RUNNING_ENV
echo $ECHO_E"\033[40mVanilla App: $APP_NAME is running \033[0m\n"
}
show_usage()
{
echo $ECHO_E"`printf %-16s "Usage: $0"` -h show this help info"
echo $ECHO_E"`printf %-16s ` -a VANILLA_APP_ROOT, app absolute path(which path to init app)"
echo $ECHO_E"`printf %-16s ` -u VANILLA_APP_USER, user to run app"
echo $ECHO_E"`printf %-16s ` -g VANILLA_APP_GROUP, user group to run app"
echo $ECHO_E"`printf %-16s ` -e VANILLA_RUNNING_ENV, app running environment"
}
while getopts a:u:g:e:h OPT; do
case "$OPT" in
a )
VANILLA_APP_ROOT=$OPTARG
;;
u )
VANILLA_APP_USER=$OPTARG
;;
g )
VANILLA_APP_GROUP=$OPTARG
;;
e )
VANILLA_RUNNING_ENV=$OPTARG
;;
h )
show_usage && exit 0
;;
-- )
shift break
;;
? )
alert "ERROR: unknown argument!" && show_usage && exit 1
;;
esac
done
APP_NAME=`basename $VANILLA_APP_ROOT`
init_vanilla_app $VANILLA_APP_ROOT $VANILLA_APP_USER $VANILLA_APP_GROUP $APP_NAME $VANILLA_RUNNING_ENV
echo
echo $ECHO_E"You are setup $APP_NAME and using:"
echo $ECHO_E"`printf %-36s "\"$VANILLA_APP_ROOT\""` ---- as vanilla app root"
echo $ECHO_E"`printf %-36s "\"$VANILLA_RUNNING_ENV\""` ---- as running environment"
echo $ECHO_E"`printf %-36s "\"$VANILLA_APP_USER\""` ---- as vanilla app nginx user"
echo $ECHO_E"`printf %-36s "\"$VANILLA_APP_GROUP\""` ---- as vanilla app nginx group"
echo
exit 0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/beck_bi/vanilla.git
git@gitee.com:beck_bi/vanilla.git
beck_bi
vanilla
vanilla
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385