-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker.conf.sh
More file actions
263 lines (226 loc) · 6.79 KB
/
docker.conf.sh
File metadata and controls
263 lines (226 loc) · 6.79 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
DOCKER_HOME="."
DOCKER_BUILD_DIR="."
CONTAINER_NAME=archive-solr
DOCKER_FILE=Dockerfile
RUN_VOLUMES=(
# DATA
"./data:/var/solr:rw,z"
# defconfig jars
"./lib/GreekToGreeklishConverter9.jar:/defconfig/lib/GreekToGreeklishConverter9.jar:rw"
"./lib/GreekToGreeklishConverter7.jar:/defconfig/lib/GreekToGreeklishConverter7.jar:rw"
"./lib/commons-lang3.jar:/defconfig/lib/commons-lang3.jar:rw"
# defconfig schemas
"./index_schemas:/defconfig/indexes/:rw,z"
# LOGS
#"./data/logs:/var/solr/logs/:rw"
)
RG_SOLR_JAR=GreekToGreeklishConverter9.jar
SOLR_UID=1000
RUN_PORTS=("127.0.0.1:8983:8983")
RUN_PARAMS=("-d" "-it" "--restart always")
if [[ -f "${__DOCKERSH_CONFIG_DIR}/solr.env" ]]; then
#echo "source solr.env"
source "${__DOCKERSH_CONFIG_DIR}/solr.env"
fi
RUN_ENV=(
"SOLR_UID=${SOLR_UID}"
"RG_SOLR_JAR=${RG_SOLR_JAR}"
)
CUSTOM_ACTIONS=(
"status|action_solr_status| solr status"
"solr_status|action_solr_status| solr status"
"solr_status_check|action_solr_status_check| solr status (if fail recheck after while)"
"solr|action_solr| solr"
"solr_post|action_post| solr/bin post"
"solr_version|action_solr_version| solr version"
"solr_data_version|action_solr_dataversion| solr_data version"
"solr_stop|action_solr_stop| solr stop"
"solr_restart|action_solr_restart| solr restart (stop/start)"
"solr_rerun|action_solr_rerun| solr rerun (remove/run)"
"solr_start|action_solr_rerun| solr rerun (remove/run)"
"docker_restart|action_docker_stop_start| docker stop , docker start"
"solr_schemas|action_solr_schemas| list schemas"
"solr_indexes|action_solr_indexes| list indexes from solr_data dir"
"solr_remove_index|action_solr_remove_index| solr remove index"
"solr_create_index|action_solr_create_index| solr create index"
"solr_reload_index|action_solr_index_reload| solr reload index"
"solr_create_core|action_solr_create_core| solr create core with defaults"
"solr_cp_core_conf|action_solr_copy_core_config|solr copy configs to core"
"solr_list_cores|action_solr_list_cores| solr list cores"
"solr_list_cores_e|action_solr_list_cores_full| solr list cores extend json format"
"solr_show_core|action_solr_show_core| solr show core"
"solr_logs|action_solr_logs| tail -f solr logs"
"solr_logs_cat|action_solr_logs_cat| cat solr logs"
"solr_port|action_solr_port| prints solr port"
"solr_chrome|action_solr_chrome| open solr admin interface in chrome"
"solr_query|action_solr_query|"
"solr_query_ext|action_solr_query_ext|"
)
_get_port () {
echo ${RUN_PORTS}|awk -F ':' '{print $(NF-1)}'
}
_urlencode() {
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%s' "$c" | xxd -p -c1 |
while read c; do printf '%%%s' "$c"; done ;;
esac
done
}
action_solr_check_port () {
SOLR_PORT=$(action_solr_port);
TEST_NETSTAT=`netstat -ln|grep ${SOLR_PORT}|grep -v grep|grep -v tcp6|wc -l`;
#docker_exec /opt/solr/bin/solr status|sed "s/on port 8983/on port ${SOLR_PORT}/"
if [ "x${SOLR_PORT}" != "x8983" ]; then
echo "-------------------------------------------------"
echo "SOLR EXTERNAL PORT ${SOLR_PORT}"
echo "SOLR INTERNAL PORT 8983"
echo "-------------------------------------------------"
fi
if [ "x${TEST_NETSTAT}" != "x1" ]; then
>&2 echo -e "${COLOR_RED}SOLR NOT LISTEN IN PORT ${SOLR_PORT}${COLOR_RESET}"
fi
}
action_solr_status () {
action_solr_check_port
docker_exec /opt/solr/bin/solr status
}
action_solr_status_check () {
action_solr_check_port
docker_exec /opt/solr/bin/solr_status_check.sh
}
action_solr_version () {
docker_exec /opt/solr/bin/solr version
}
action_solr () {
docker_exec /opt/solr/bin/solr "$@"
}
action_post () {
docker_exec /opt/solr/bin/post "$@"
}
action_solr_list_cores () {
docker_exec /opt/solr/bin/listCores.sh "$@"
}
action_solr_show_core (){
if [ "x$1" == "x" ]; then
echo "CORE NAME EXPECTED";
fi
docker_exec /opt/solr/bin/listCores.sh "$@"
}
action_solr_list_cores_full () {
docker_exec /opt/solr/bin/listCores.sh --full
}
action_solr_remove_index () {
docker_exec /opt/solr/bin/removeIndex.sh "$@"
}
action_solr_create_index () {
docker_exec /opt/solr/bin/buildIndex.sh "$@"
}
action_solr_copy_core_config () {
docker_exec /opt/solr/bin/copyCoreConfig.sh "$@"
}
action_solr_create_core () {
docker_exec /opt/solr/bin/createCore.sh "$@"
}
action_solr_restart () {
echo -e "${COLOR_GREEN}SOLR STOP ${COLOR_RESET}";
#docker_exec /opt/solr/bin/solr stop -all
#docker_exec /opt/solr/bin/solr stop -p ${PORT}
docker_exec /opt/solr/bin/solr_stop.sh
sleep 2;
action_solr_status_check
}
action_docker_stop_start () {
echo -e "${COLOR_GREEN}docker stop ${COLOR_RESET}";
_stop
echo -e "${COLOR_GREEN}docker start${COLOR_RESET}";
_start
}
action_solr_stop () {
#PORT=`_get_port`;
#echo -e "${COLOR_GREEN}SOLR STOP${COLOR_RESET}";
#solr stop -all
#docker_exec /opt/solr/bin/solr stop -p ${PORT}
#sleep 2;
echo -e "${COLOR_GREEN}DOCKER REMOVE${COLOR_RESET}";
_remove
}
action_solr_rerun () {
echo -e "${COLOR_GREEN}DOCKER REMOVE${COLOR_RESET}";
_remove
echo -e "${COLOR_GREEN}RUN${COLOR_RESET}";
_run
echo -e "${COLOR_GREEN}STATUS${COLOR_RESET}";
sleep 2;
action_solr_status_check
}
action_solr_logs () {
DOCKER_LOGS_DIR=/var/solr/logs/
docker_exec tail -f ${DOCKER_LOGS_DIR}/solr.log
#docker_exec tail -f ${DOCKER_LOGS_DIR}/solr_gc.log ${DOCKER_LOGS_DIR}/solr.log
}
action_solr_logs_cat () {
DOCKER_LOGS_DIR=/var/solr/logs/
docker_exec cat ${DOCKER_LOGS_DIR}/solr.log
}
action_solr_dataversion () {
docker_exec /opt/solr/bin/solrDataVersion.sh
}
action_solr_indexes () {
docker_exec /opt/solr/bin/listIndexes.sh
}
action_solr_schemas () {
docker_exec /opt/solr/bin/listSchemas.sh
}
action_solr_index_reload(){
docker_exec /opt/solr/bin/reloadIndex.sh "$@"
}
action_solr_port(){
PORT=`_get_port`;
echo $PORT;
}
action_solr_chrome(){
SOLR_PORT=$(action_solr_port);
URL="http://localhost:$SOLR_PORT";
echo "$URL";
google-chrome $URL;
}
action_solr_query(){
docker_exec /opt/solr/bin/query.sh "$@"
}
action_solr_query_ext(){
#echo "$DOCKER_HOME_FULL"
PORT=`_get_port`;
INDEX_NAME="$1";
if [ "x${INDEX_NAME}" == "x" ]; then
>&2 echo "ERROR: INDEX_NAME (CORE) EXPECTED";
action_solr_list_cores
exit;
fi
Q="$2"
if [ "x${Q}" == "x" ]; then
Q="*%3A*";
else
Q=`_urlencode "$2"`
fi
if [ "x${SOLR_QUERY_PARAMS}" == "x" ]; then
if [ -f "${DOCKER_HOME_FULL}/cores/${INDEX_NAME}/ENV" ]; then
source "${DOCKER_HOME_FULL}/cores/${INDEX_NAME}/ENV"
fi
if [ "x${SOLR_QUERY_PARAMS_ARRAY}" != "x" ]; then
SEP=''
for P in ${SOLR_QUERY_PARAMS_ARRAY[@]}; do
SOLR_QUERY_PARAMS="${SOLR_QUERY_PARAMS}${SEP}${P}"
SEP='&'
done
#echo ${SOLR_QUERY_PARAMS}
fi
fi
URL="http://127.0.0.1:${PORT}/solr/${INDEX_NAME}/select?q=${Q}&rows=1000&wt=json&indent=true&${SOLR_QUERY_PARAMS}"
#echo $URL;
#curl "${URL}"|json_pp
curl "${URL}" 2>/dev/null
}