2020-09-11 12:29:29 -04:00
|
|
|
#!/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
|
2020-11-27 14:59:54 -05:00
|
|
|
#echo "Creating $DIR/data"
|
2020-09-11 12:29:29 -04:00
|
|
|
check_dir_writability "$DIR"
|
2020-11-27 14:59:54 -05:00
|
|
|
mkdir -m0770 "$DIR/data"
|
2020-09-11 12:29:29 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$DIR/logs" ]; then
|
2020-11-27 14:59:54 -05:00
|
|
|
#echo "Creating $DIR/logs"
|
2020-09-11 12:29:29 -04:00
|
|
|
check_dir_writability "$DIR"
|
2020-11-27 14:59:54 -05:00
|
|
|
mkdir -m0770 "$DIR/logs"
|
2020-09-11 12:29:29 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$DIR/data/solr.xml" ]; then
|
2020-11-27 14:59:54 -05:00
|
|
|
#echo "Copying solr.xml"
|
2020-09-11 12:29:29 -04:00
|
|
|
cp -a /opt/solr/server/solr/solr.xml "$DIR/data/solr.xml"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$DIR/data/zoo.cfg" ]; then
|
2020-11-27 14:59:54 -05:00
|
|
|
#echo "Copying zoo.cfg"
|
2020-09-11 12:29:29 -04:00
|
|
|
cp -a /opt/solr/server/solr/zoo.cfg "$DIR/data/zoo.cfg"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$DIR/log4j2.xml" ]; then
|
2020-11-27 14:59:54 -05:00
|
|
|
#echo "Copying log4j2.xml"
|
2020-09-11 12:29:29 -04:00
|
|
|
cp -a /opt/solr/server/resources/log4j2.xml "$DIR/log4j2.xml"
|
|
|
|
fi
|
|
|
|
|