-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_odp.sh
executable file
·175 lines (148 loc) · 4.72 KB
/
install_odp.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
set -e
trap 'echo Error on line $BASH_SOURCE:$LINENO' ERR
trap 'rm -f $tmp' EXIT
START=`date +%s`;
#JUMBO_REPO="http://jumbo.baidu.com"
JUMBO_REPO="ftp://getprod:[email protected]/data/prod-64/inf/odp/jumbo-repo/jumbo-repo_1-0-0_BL/output"
JUMBO_LOCATION=$JUMBO_REPO/jumbo
DEFAULT_JUMBO_ROOT=$HOME/.jumbo
usage()
{
cat <<"EOT";
Usage: install ODP environment script [-options]
-d Please enter the full path of the directory in which
You want to install ODP environment$
-t Choose the ODP environment type , (online) or (develop)
-s Choose the webserver for ODP environment (lighttpd) or (nginx)
Also you cloud use the other two options
-v Show install odp version
--help Print this message
EOT
}
odp_build_repo()
{
rm -rf installs
mkdir installs
find packages -name "*.jumbo" | xargs -i{} cp {} installs/
f="$PWD/tmp.tar"
final="$PWD/list.tar.gz"
(
cd installs
ls | while read i
do
pkgname_expected=${i%.jumbo}
[ "$pkgname_expected" == "$i" ] && continue
(
. "$i" && [ "$pkgname" == "$pkgname_expected" ]
) || continue
tar -rf "$f.tmp" "$i"
done
if [ -f "$f.tmp" ]
then
mv "$f.tmp" "$f"
gzip "$f"
mv "$f.gz" "$final"
fi
)
}
if test $# -eq 0
then
usage
exit
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//') ;;
*) optarg= ;;
esac
case $1 in
-d=*)
ODP_ROOT=$optarg
;;
-t=*)
ODP_TYPE=$optarg
;;
-s=*)
ODP_SERVER=$optarg
;;
-v)
echo "ODP 2.4.0 INSTALL PACKAGE"
exit 0
;;
--help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
shift
done
if [ -d "$ODP_ROOT" ]
then
echo -e "\033[31;1m [ERROR OCCURRED] \033[37;1m"
echo -e "\033[32;1m The PATH to install ODP environment is already exits. \033[37;1m"
echo -e "\033[32;1m Please use -d option to specify a valid path... \033[37;1m"
exit 3
fi
if [ -z "$ODP_ROOT" ]
then
#JUMBO_ROOT="$DEFAULT_JUMBO_ROOT"
echo -e "\033[31;1m [ERROR OCCURRED] \033[37;1m"
echo -e "\033[32;1m You did not specified a PATH to install ODP environment. \033[37;1m"
echo -e "\033[32;1m Please use -d option to specify a valid path... \033[37;1m"
exit 3
fi
if [ -z "$ODP_TYPE" ]
then
echo -e "\033[31;1m [ERROR OCCURRED] \033[37;1m"
echo -e "\033[32;1m You did not specified the ODP environment's type. \033[37;1m"
echo -e "\033[32;1m Please use -t option to specify a valid type... \033[37;1m"
echo -e "\033[32;1m There has two types for you to choose: -t=online / -t=develop \033[37;1m"
exit 4
fi
if [ "$ODP_TYPE" != "online" ] && [ "$ODP_TYPE" != "develop" ]
then
echo -e "\033[31;1m [ERROR OCCURRED] \033[37;1m"
echo -e "\033[32;1m You did not specified a valid ODP environment type. \033[37;1m"
echo -e "\033[32;1m Please use -t option to specify a valid type... \033[37;1m"
echo -e "\033[32;1m There has two types for you to choose: -t=online / -t=develop \033[37;1m"
exit 4
fi
if [ -z "$ODP_SERVER" ]
then
echo -e "\033[31;1m [ERROR OCCURRED] \033[37;1m"
echo -e "\033[32;1m You did not specified the ODP environment's webserver. \033[37;1m"
echo -e "\033[32;1m Please use -s option to specify a valid webserver... \033[37;1m"
echo -e "\033[32;1m There has two types for you to choose: -s=lighttpd / -s=nginx \033[37;1m"
exit 4
fi
if [ "$ODP_SERVER" != "lighttpd" ] && [ "$ODP_SERVER" != "nginx" ]
then
echo -e "\033[31;1m [ERROR OCCURRED] \033[37;1m"
echo -e "\033[32;1m You did not specified a valid ODP environment's webserver. \033[37;1m"
echo -e "\033[32;1m Please use -s option to specify a valid webserver... \033[37;1m"
echo -e "\033[32;1m There has two types for you to choose: -s=lighttpd / -s=nginx \033[37;1m"
exit 4
fi
if [ "${ODP_ROOT:0:1}" != "/" ]
then
JUMBO_ROOT="$PWD/$JUMBO_ROOT"
else
JUMBO_ROOT=$ODP_ROOT
fi
mkdir -p "$JUMBO_ROOT"
cd jumbo
./jumbo-0.6.3 -n -r "$JUMBO_ROOT" -p "$JUMBO_REPO" local-install jumbo.jumbo
cd ../
$JUMBO_ROOT/bin/jumbo update jumbo &>/dev/null
echo 'ftp://getprod:[email protected]/data/prod-64/inf/odp/jumbo-repo/jumbo-repo_1-0-0_BL/output' >>$JUMBO_ROOT/etc/jumbo-repo.conf
odp_build_repo
#cd packages
$JUMBO_ROOT/bin/jumbo -p "file://$PWD" check
$JUMBO_ROOT/bin/jumbo -p "file://$PWD" install odp-${ODP_TYPE}-${ODP_SERVER}
END=`date +%s`;
echo Time costs : `expr $END - $START`s