-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-env.sh
executable file
·99 lines (83 loc) · 3.98 KB
/
init-env.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
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
####################################################################
# This script is used to initial environment of DataX
####################################################################
set -eo pipefail
DATAX_EXTENSION_HOME=`dirname "$0"`
DATAX_EXTENSION_HOME=`cd "$DATAX_EXTENSION_HOME"; pwd`
export DATAX_EXTENSION_HOME
DATAX_GITHUB=https://github.com/alibaba/DataX.git
DORISWRITER_DIR=$DATAX_EXTENSION_HOME/selectdbwriter
DATAX_GIT_DIR=$DATAX_EXTENSION_HOME/DataX/
DATAX_POM=$DATAX_EXTENSION_HOME/DataX/pom.xml
DATAX_PACKAGE=$DATAX_EXTENSION_HOME/DataX/package.xml
DATAX_CORE_POM=$DATAX_EXTENSION_HOME/DataX/core/pom.xml
USE_MACOS=0
# check OS type
if [[ ! -z "$OSTYPE" ]]; then
if [[ ${OSTYPE:0:6} == "darwin" ]]; then
USE_MACOS=1
fi
fi
if [ ! -d $DATAX_GIT_DIR ]; then
echo "Clone DataX from $DATAX_GITHUB"
git clone $DATAX_GITHUB $DATAX_GIT_DIR
ln -s $DORISWRITER_DIR $DATAX_GIT_DIR/selectdbwriter
else
echo "DataX code repo exists in $DATAX_GIT_DIR"
fi
if [ ! -f "$DATAX_POM" ]; then
echo "$DATAX_POM does not exist, exit"
exit 1
fi
if [ `grep -c "selectdbwriter" $DATAX_POM` -eq 0 ]; then
echo "No selectdbwriter module in $DATAX_POM, add it"
if [[ USE_MACOS -eq 0 ]];then
cp $DATAX_POM ${DATAX_POM}.orig
sed -i "s/<\/modules>/ <module>selectdbwriter<\/module>\n <\/modules>/g" $DATAX_POM
else
sed -i '.orig' "s/<\/modules>/ <module>selectdbwriter<\/module>\n <\/modules>/g" $DATAX_POM
fi
else
echo "selectdbwriter module exists in $DATAX_POM"
fi
if [ `grep -c "selectdbwriter" $DATAX_PACKAGE` -eq 0 ]; then
echo "No selectdbwriter module in $DATAX_PACKAGE, add it"
if [[ USE_MACOS -eq 0 ]];then
cp $DATAX_PACKAGE ${DATAX_PACKAGE}.orig
sed -i "s/<\/fileSets>/ <fileSet>\n <directory>selectdbwriter\/target\/datax\/<\/directory>\n <includes>\n <include>**\/*.*<\/include>\n <\/includes>\n <outputDirectory>datax<\/outputDirectory>\n <\/fileSet>\n <\/fileSets>/g" $DATAX_PACKAGE
else
sed -i '.orig' "s/<\/fileSets>/ <fileSet>\n <directory>selectdbwriter\/target\/datax\/<\/directory>\n <includes>\n <include>**\/*.*<\/include>\n <\/includes>\n <outputDirectory>datax<\/outputDirectory>\n <\/fileSet>\n <\/fileSets>/g" $DATAX_PACKAGE
fi
else
echo "selectdbwriter module exists in $DATAX_PACKAGE"
fi
if [ `grep -c "4.5.13" $DATAX_CORE_POM` -eq 0 ]; then
echo "No httpclient 4.5.13 in $DATAX_CORE_POM, add it"
if [[ USE_MACOS -eq 0 ]];then
cp $DATAX_CORE_POM ${DATAX_CORE_POM}.orig
sed -i ":a;N;s/<artifactId>httpclient<\/artifactId>\n <version>4.5<\/version>/<artifactId>httpclient<\/artifactId>\n <version>4.5.13<\/version>/g" $DATAX_CORE_POM
else
sed -i '.orig' -e "N" -e "s/<artifactId>httpclient<\/artifactId>\n <version>4.5<\/version>/<artifactId>httpclient<\/artifactId>\n <version>4.5.13<\/version>/g" $DATAX_CORE_POM
fi
else
echo "httpclient 4.5.13 exists in $DATAX_CORE_POM"
fi
cp $DATAX_POM $DATAX_EXTENSION_HOME
echo "Finish DataX environment initialization"