This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
forked from 2degrees/docker-solr4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·123 lines (91 loc) · 3.15 KB
/
build.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
#!/bin/bash
# Make Bash intolerant to errors
set -o nounset
set -o errexit
set -o pipefail
# ===== Constants and functions
SOLR_DOWNLOAD_PATH="/tmp/solr.tgz"
RUNTIME_DEPENDENCIES="cgroup-tools=0.41-6"
function download_file() {
local origin_url="$1"
local destination_path="$2"
local sha1_checksum="$3"
wget --no-verbose "--output-document=${destination_path}" "${origin_url}"
check_file_sha1_sum "${destination_path}" "${sha1_checksum}"
}
function check_file_sha1_sum() {
local file_path="$1"
local expected_sha1_checksum="$2"
local actual_sha1_checksum="$(sha1sum "${file_path}" | awk '{ print $1 }')"
if [[ "${expected_sha1_checksum}" != "${actual_sha1_checksum}" ]]; then
echo "File '${file_path}' did not pass integrity check" >&2
exit 1
fi
}
function expand_tgz() {
local compressed_file_path="$1"
local destination_dir_path="$2"
local extra_tar_args="${@:3}"
tar \
--extract \
--directory "${destination_dir_path}" \
--file "${compressed_file_path}" \
${extra_tar_args}
rm "${compressed_file_path}"
}
function deploy_solr_distribution() {
local mirror_url="$1"
local solr_download_url="${mirror_url}/solr-${SOLR_VERSION}.tgz"
download_file \
"${solr_download_url}" \
"${SOLR_DOWNLOAD_PATH}" \
"${SOLR_SHA1_CHECKSUM}"
mkdir --parents "${SOLR_DISTRIBUTION_PATH}"
expand_tgz \
"${SOLR_DOWNLOAD_PATH}" \
"${SOLR_DISTRIBUTION_PATH}" \
--strip-components=1
}
function configure_solr_home() {
mkdir --parents "${SOLR_HOME_PATH}"
cp \
"${SOLR_DISTRIBUTION_PATH}/example/solr/collection1/conf/solrconfig.xml" \
"${SOLR_DISTRIBUTION_PATH}/example/solr/solr.xml" \
"${SOLR_HOME_PATH}"
mkdir "${SOLR_HOME_PATH}/cores"
mkdir --parents "${SOLR_INDICES_DIR_PATH}"
chown "${SOLR_USER}" "${SOLR_INDICES_DIR_PATH}"
}
function configure_jetty_home() {
mkdir --parents "${JETTY_HOME_PATH}"
cp \
--recursive \
"${SOLR_DISTRIBUTION_PATH}/example/contexts" \
"${SOLR_DISTRIBUTION_PATH}/example/etc" \
"${SOLR_DISTRIBUTION_PATH}/example/lib" \
"${SOLR_DISTRIBUTION_PATH}/example/webapps" \
"${JETTY_HOME_PATH}"
local solr_temp_dir_path="${JETTY_HOME_PATH}/solr-webapp"
mkdir "${solr_temp_dir_path}"
chown "${SOLR_USER}" "${solr_temp_dir_path}"
}
function install_deb_packages() {
local package_specs="${@}"
apt-get update --option "Acquire::Check-Valid-Until=false" --option "Acquire::Retries=3" --quiet=2
apt-get install \
--option "Acquire::Check-Valid-Until=false" \
--option "Acquire::Retries=3" \
--no-install-recommends \
--assume-yes \
--quiet=2 \
${@}
rm -rf /var/lib/apt/lists/*
}
# ===== Main
echo "deb http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list
adduser --system "${SOLR_USER}"
deploy_solr_distribution "$1"
configure_solr_home
configure_jetty_home
install_deb_packages ${RUNTIME_DEPENDENCIES}