forked from idevz/vanilla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-framework
executable file
·89 lines (75 loc) · 2.66 KB
/
setup-framework
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
### BEGIN ###
# Author: idevz
# Since: 2016/04/09
# Description: Setup Vanilla Framework
### END ###
VANILLA_VERSION=0.1.0.rc6
VANILLA_VERSION_DIR_STR=0_1_0_rc6
VANILLA_PROJ_ROOT=/data/vanilla
OPENRESTY_ROOT=/usr/local/openresty
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"
}
install_vanilla_framework()
{
echo $ECHO_E"\033[45mBegin install Vanilla Frameowrk! \033[0m\n"
VANILLA_PROJ_ROOT=$1
VANILLA_FRAMEWORK_ROOT=$1/framework
VANILLA_FRAMEWORK_V=$VANILLA_FRAMEWORK_ROOT/$VANILLA_VERSION_DIR_STR
[ -n $2 ] && OPENRESTY_ROOT=$2
[ ! -d $OPENRESTY_ROOT ] && alert "OPENRESTY_ROOT set ERROR, OpenResty Path "$OPENRESTY_ROOT" didn't exist, and -o to set the ture OPENRESTY_ROOT" && exit 1
VANILLA_BIN=/usr/local/bin/vanilla-$VANILLA_VERSION
VANILLA_CONSOLE_BIN=/usr/local/bin/v-console-$VANILLA_VERSION
echo $VANILLA_FRAMEWORK_V
[ -f $VANILLA_BIN ] && mv -f $VANILLA_BIN $VANILLA_BIN".old_"$TIME_MARK
[ -f $VANILLA_CONSOLE_BIN ] && mv -f $VANILLA_CONSOLE_BIN $VANILLA_CONSOLE_BIN".old_"$TIME_MARK
[ -d $VANILLA_FRAMEWORK_V ] && mv -f $VANILLA_FRAMEWORK_V $VANILLA_FRAMEWORK_V".old_"$TIME_MARK
make clean
./configure --prefix=$VANILLA_FRAMEWORK_ROOT --openresty-path=$OPENRESTY_ROOT
make install
if [[ $? -ne 0 ]];then
alert "Install Vanilla Frameowrk Fail. Pleas check your access permissions."
exit 1
fi
echo $ECHO_E"\033[35mVanilla Frameowrk Installed $VANILLA_FRAMEWORK_ROOT \033[0m\n"
}
show_usage()
{
echo $ECHO_E"`printf %-16s "Usage: $0"`"
echo $ECHO_E"`printf %-16s ` -h show this help info"
echo $ECHO_E"`printf %-16s ` -v VANILLA_PROJ_ROOT, vanilla project root, will contain vanilla framework and apps"
echo $ECHO_E"`printf %-16s ` -o OPENRESTY_ROOT, openresty install path(openresty root)"
}
while getopts v:o:h OPT; do
case "$OPT" in
v )
VANILLA_PROJ_ROOT=$OPTARG
;;
o )
OPENRESTY_ROOT=$OPTARG
;;
h )
show_usage && exit 0
;;
-- )
shift break
;;
? )
alert "ERROR: unknown argument!" && show_usage && exit 1
;;
esac
done
install_vanilla_framework $VANILLA_PROJ_ROOT $OPENRESTY_ROOT
echo
echo $ECHO_E"You are setup Vanilla-$VANILLA_VERSION and using:"
echo $ECHO_E"`printf %-30s "\"$OPENRESTY_ROOT\""` ---- as OpenResty install path(OpenResty root)"
echo $ECHO_E"`printf %-30s "\"$VANILLA_PROJ_ROOT\""` ---- as vanilla project root(will contain vanilla framework and apps)"
echo
exit 0