-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·177 lines (151 loc) · 5.8 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·177 lines (151 loc) · 5.8 KB
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
176
177
#!/usr/bin/env bash
# three threads is the best parallelism
mvn -T 3 clean install
if [ $? -ne 0 ]; then
echo "ERROR: Maven package failed. Stop installing Pixels."
exit 1
fi
if [ -z "$PIXELS_HOME" ]; then
echo "ERROR: PIXELS_HOME is not set. Stop installing Pixels."
exit 1
else
echo "PIXELS_HOME is '$PIXELS_HOME'"
fi
# remove the last '/', this is optional, but makes the output look better
if [[ "$PIXELS_HOME" == *"/" ]]
then
PIXELS_HOME=${PIXELS_HOME::-1}
fi
mkdir -p $PIXELS_HOME/bin
mkdir -p $PIXELS_HOME/sbin
mkdir -p $PIXELS_HOME/etc
mkdir -p $PIXELS_HOME/lib
mkdir -p $PIXELS_HOME/listener
mkdir -p $PIXELS_HOME/logs
mkdir -p $PIXELS_HOME/var
echo "Installing pixels-index-rockset JNI library..."
ROCKSET_JNI_LIB=./cpp/pixels-index/pixels-index-rockset/build/libpixels-index-rockset.so
if [ ! -f "$ROCKSET_JNI_LIB" ]; then
echo "WARN: '$ROCKSET_JNI_LIB' not found. Skip installing pixels-index-rockset JNI library."
echo "WARN: Build it manually if you need Rockset index support. See cpp/pixels-index/pixels-index-rockset/README.md."
else
cp -v "$ROCKSET_JNI_LIB" $PIXELS_HOME/lib
fi
echo "Installing scripts..."
CP_SBIN=0
if [ -z "$(ls -A $PIXELS_HOME/sbin)" ]; then
CP_SBIN=1
else
read -p "'$PIXELS_HOME/sbin' not empty, override?[y/n]" -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
CP_SBIN=1
fi
fi
if [ $CP_SBIN -eq 1 ]; then
cp -v ./scripts/sbin/* $PIXELS_HOME/sbin
fi
CP_BIN=0
if [ -z "$(ls -A $PIXELS_HOME/bin)" ]; then
CP_BIN=1
else
read -p "'$PIXELS_HOME/bin' not empty, override?[y/n]" -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
CP_BIN=1
fi
fi
if [ $CP_BIN -eq 1 ]; then
cp -v ./scripts/bin/* $PIXELS_HOME/bin
fi
echo "Installing pixels-daemons..."
cp -v ./pixels-daemon/target/pixels-daemon-*-full.jar $PIXELS_HOME/bin
echo "Installing pixels-cli..."
cp -v ./pixels-cli/target/pixels-cli-*-full.jar $PIXELS_HOME/sbin
if [ -z "$(ls -A $PIXELS_HOME/lib)" ]; then
echo "$(
tput setaf 1
tput setab 7
)Make sure to put the jdbc connector of MySQL into '$PIXELS_HOME/lib'!$(tput sgr 0)"
fi
echo "Installing config files..."
# copy the jvm and worker nodes config files
CP_ETC=0
if [ -z "$(ls -A $PIXELS_HOME/etc)" ]; then
CP_ETC=1
else
read -p "'$PIXELS_HOME/etc' not empty, override?[y/n]" -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
CP_ETC=1
fi
fi
if [ $CP_ETC -eq 1 ]; then
cp -v ./scripts/etc/* $PIXELS_HOME/etc
fi
# find and copy pixels.properties
if [ ! -f "$PIXELS_HOME/etc/pixels.properties" ]; then
cp -v ./pixels-common/src/main/resources/pixels.properties $PIXELS_HOME/etc
echo "$(
tput setaf 1
tput setab 7
)Make sure to modify '$PIXELS_HOME/etc/pixels.properties'!$(tput sgr 0)"
else
TEMPLATE_KEYS=$(mktemp)
TARGET_KEYS=$(mktemp)
NEW_KEYS=$(mktemp)
DEPRECATED_KEYS=$(mktemp)
NEW_OPTIONS=$(mktemp)
DEPRECATED_OPTIONS=$(mktemp)
sed -n '/^[[:space:]]*#/d; /^[[:space:]]*$/d; /=/ { s/[[:space:]]*=.*$//; s/^[[:space:]]*//; p; }' ./pixels-common/src/main/resources/pixels.properties | sort -u > $TEMPLATE_KEYS
sed -n '/^[[:space:]]*#/d; /^[[:space:]]*$/d; /=/ { s/[[:space:]]*=.*$//; s/^[[:space:]]*//; p; }' $PIXELS_HOME/etc/pixels.properties | sort -u > $TARGET_KEYS
comm -13 $TARGET_KEYS $TEMPLATE_KEYS > $NEW_KEYS
comm -23 $TARGET_KEYS $TEMPLATE_KEYS > $DEPRECATED_KEYS
if [ -s $NEW_KEYS ]; then
awk -F= 'FNR==NR { keys[$1]=1; next } /^[[:space:]]*#/ || /^[[:space:]]*$/ || index($0, "=") == 0 { next } { key=$1; gsub(/^[[:space:]]+|[[:space:]]+$/, "", key); if (key in keys) print $0 }' $NEW_KEYS ./pixels-common/src/main/resources/pixels.properties > $NEW_OPTIONS
echo "new config option:"
sed 's/^/ /' $NEW_OPTIONS
read -p "add new config options to '$PIXELS_HOME/etc/pixels.properties'?[Y/n]" -n 1 -r
echo # move to a new line
if [[ -z $REPLY || $REPLY =~ ^[Yy]$ ]]; then
echo >> $PIXELS_HOME/etc/pixels.properties
cat $NEW_OPTIONS >> $PIXELS_HOME/etc/pixels.properties
fi
fi
if [ -s $DEPRECATED_KEYS ]; then
awk -F= 'FNR==NR { keys[$1]=1; next } /^[[:space:]]*#/ || /^[[:space:]]*$/ || index($0, "=") == 0 { next } { key=$1; gsub(/^[[:space:]]+|[[:space:]]+$/, "", key); if (key in keys) print $0 }' $DEPRECATED_KEYS $PIXELS_HOME/etc/pixels.properties > $DEPRECATED_OPTIONS
echo "deprecated config option:"
sed 's/^/ /' $DEPRECATED_OPTIONS
read -p "remove deprecated config options from '$PIXELS_HOME/etc/pixels.properties'?[y/N]" -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
TMP_PIXELS_PROPERTIES=$(mktemp)
awk -F= 'FNR==NR { keys[$1]=1; next } { line=$0; key=$1; if (line ~ /^[[:space:]]*#/ || line ~ /^[[:space:]]*$/ || index(line, "=") == 0) { print line; next } gsub(/^[[:space:]]+|[[:space:]]+$/, "", key); if (!(key in keys)) print line }' $DEPRECATED_KEYS $PIXELS_HOME/etc/pixels.properties > $TMP_PIXELS_PROPERTIES
mv $TMP_PIXELS_PROPERTIES $PIXELS_HOME/etc/pixels.properties
fi
fi
rm -f $TEMPLATE_KEYS $TARGET_KEYS $NEW_KEYS $DEPRECATED_KEYS $NEW_OPTIONS $DEPRECATED_OPTIONS
fi
# find and copy pixels-cpp.properties
if [ -z "$(find $PIXELS_HOME/etc -name "pixels-cpp.properties")" ]; then
cp -v ./cpp/pixels-cpp.properties $PIXELS_HOME/etc
echo "$(
tput setaf 1
tput setab 7
)Make sure to modify '$PIXELS_HOME/etc/pixels-cpp.properties'!$(tput sgr 0)"
else
read -p "'$PIXELS_HOME/etc/pixels-cpp.properties' exists, override?[y/n]" -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
cp -v ./cpp/pixels-cpp.properties $PIXELS_HOME/etc
fi
fi
# prompt the post-install steps
echo "$(
tput setaf 1
tput setab 7
)You may need to install and configure MySQL and etcd. Please refer to README.$(tput sgr 0)"
echo "$(
tput setaf 1
tput setab 7
)See the README of pixels-presto/trino/hive to install a query engine.$(tput sgr 0)"