forked from docker-solr/docker-solr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-var-solr
executable file
·61 lines (49 loc) · 1.27 KB
/
init-var-solr
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
#!/bin/bash
#
# A helper script to initialise an empty $DIR
# If you use volumes then Docker will copy the $DIR content from the container to the volume.
# If you use bind mounts, that does not happen, so we do it here.
set -e
if [[ "$VERBOSE" == "yes" ]]; then
set -x
fi
if [[ -n "${NO_INIT_VAR_SOLR:-}" ]]; then
exit 0
fi
DIR=${1:-/var/solr}
if [ ! -d "$DIR" ]; then
echo "Missing $DIR"
exit 1
fi
function check_dir_writability {
local dir="$1"
if [ ! -w "$dir" ]; then
echo "Cannot write to $dir as $(id -u):$(id -g)"
ls -ld "$dir"
exit 1
fi
}
if [ ! -d "$DIR/data" ]; then
echo "Creating $DIR/data"
check_dir_writability "$DIR"
mkdir "$DIR/data"
chmod 0770 "$DIR/data"
fi
if [ ! -d "$DIR/logs" ]; then
echo "Creating $DIR/logs"
check_dir_writability "$DIR"
mkdir "$DIR/logs"
chmod 0770 "$DIR/logs"
fi
if [ ! -f "$DIR/data/solr.xml" ]; then
echo "Copying solr.xml"
cp -a /opt/solr/server/solr/solr.xml "$DIR/data/solr.xml"
fi
if [ ! -f "$DIR/data/zoo.cfg" ]; then
echo "Copying zoo.cfg"
cp -a /opt/solr/server/solr/zoo.cfg "$DIR/data/zoo.cfg"
fi
if [ ! -f "$DIR/log4j2.xml" ]; then
echo "Copying log4j2.xml"
cp -a /opt/solr/server/resources/log4j2.xml "$DIR/log4j2.xml"
fi