1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-12-24 07:37:04 +00:00

solr fixes

This commit is contained in:
github@kiekerjan.isdronken.nl 2021-04-26 09:40:27 +02:00
parent b1671df028
commit 7089bd2748
4 changed files with 36 additions and 34 deletions

View File

@ -1,2 +1,2 @@
* */1 * * * root /usr/bin/curl -s http://127.0.0.1:8983/solr/update?commit=true >/dev/null 2>&1 1 */1 * * * root /usr/bin/curl -s http://127.0.0.1:8983/solr/update?commit=true >/dev/null 2>&1
30 3 * * * root /usr/bin/curl -s http://127.0.0.1:8983/solr/update?optimize=true >/dev/null 2>&1 30 3 * * * root /usr/bin/curl -s http://127.0.0.1:8983/solr/update?optimize=true >/dev/null 2>&1

View File

@ -5,13 +5,12 @@ After=network.target
[Service] [Service]
Type=forking Type=forking
User=solr User=solr
PIDFile=/var/run/solr-8983.pid
Environment=SOLR_INCLUDE=/etc/default/solr.in.sh Environment=SOLR_INCLUDE=/etc/default/solr.in.sh
ExecStart=/usr/local/lib/solr/bin/solr start ExecStart=/usr/local/lib/solr/bin/solr start
ExecStop=/usr/local/lib/solr/bin/solr stop ExecStop=/usr/local/lib/solr/bin/solr stop
Restart=on-failure Restart=on-failure
ReadWritePaths=/var/lib/solr/ #ReadWritePaths=/var/lib/solr/
ReadWritePaths=/var/lib/solr/data/ #ReadWritePaths=/var/lib/solr/data/
LimitNOFILE=65000 LimitNOFILE=65000
LimitNPROC=65000 LimitNPROC=65000
TimeoutSec=180s TimeoutSec=180s

View File

@ -68,6 +68,14 @@ done
echo "include: /etc/nsd/zones.conf" >> /etc/nsd/nsd.conf; echo "include: /etc/nsd/zones.conf" >> /etc/nsd/nsd.conf;
# Add systemd override file to fix some permissions
mkdir -p /etc/systemd/system/nsd.service.d/
cat > /etc/systemd/system/nsd.service.d/nsd-permissions.conf << EOF
[Service]
ReadWritePaths=/var/lib/nsd /etc/nsd /run /var/log /run/nsd
CapabilityBoundingSet=CAP_CHOWN CAP_IPC_LOCK CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_NET_ADMIN
EOF
# Attempting a late install of nsd (after configuration) # Attempting a late install of nsd (after configuration)
apt_install nsd apt_install nsd

View File

@ -25,9 +25,6 @@ source /etc/mailinabox.conf # load global vars
echo "Installing Solr..." echo "Installing Solr..."
# TODO remove after testing
set -x
apt_install dovecot-solr default-jre-headless apt_install dovecot-solr default-jre-headless
VERSION=8.8.2 VERSION=8.8.2
@ -46,16 +43,15 @@ fi
if [ $needs_update == 1 ]; then if [ $needs_update == 1 ]; then
# install SOLR # install SOLR
wget_verify \ wget_verify \
https://www.apache.org/dyn/closer.lua?action=download&filename=lucene/solr/$VERSION/solr-$VERSION.tgz \ "https://www.apache.org/dyn/closer.lua?action=download&filename=lucene/solr/$VERSION/solr-$VERSION.tgz" \
$HASH \ $HASH \
/tmp/solr.tgz /tmp/solr.tgz
tar xzf /tmp/solr.tgz solr-$VERSION/bin/install_solr_service.sh --strip-components=2 tar xzf /tmp/solr-$VERSION.tgz -C /tmp solr-$VERSION/bin/install_solr_service.sh --strip-components=2
# install to usr/local, force update, do not start service on installation complete # install to usr/local, force update, do not start service on installation complete
bash /tmp/install_solr_service.sh solr.tgz -i /usr/local/lib -f -n bash /tmp/install_solr_service.sh /tmp/solr-$VERSION.tgz -i /usr/local/lib -f -n
# TODO uncomment after testing rm -f /tmp/solr-$VERSION.tgz
#rm -f /tmp/solr.tgz
rm -f /tmp/install_solr_service.sh rm -f /tmp/install_solr_service.sh
# stop and remove the init.d script # stop and remove the init.d script
@ -63,25 +59,20 @@ if [ $needs_update == 1 ]; then
update-rc.d solr remove update-rc.d solr remove
fi fi
# Add security
tools/editconf.py /etc/default/solr.in.sh \
SOLR_IP_WHITELIST="127.0.0.1, [::1]"
# Install systemd service # Install systemd service
if [ ! -f "/lib/systemd/system/solr.service" ]; then
cp -f conf/solr/solr.service /lib/systemd/system/solr.service cp -f conf/solr/solr.service /lib/systemd/system/solr.service
hide_output systemctl link -f /lib/systemd/system/solr.service # hide_output systemctl link -f /lib/systemd/system/solr.service
# Reload systemctl to pickup the above changes # Reload systemctl to pickup the above changes
hide_output systemctl daemon-reload hide_output systemctl daemon-reload
fi
# Make sure service is enabled # Make sure service is enabled
hide_output systemctl enable solr.service hide_output systemctl enable solr.service
# TODO: necessary? Solr requires a schema to tell it how to index data, this is provided by dovecot
# cp -f /usr/share/dovecot/solr-schema.xml /etc/solr/conf/schema.xml
# Default config has an error with our config, placing our custom version
# TBD necessary?
#cp -f conf/solr/solr-jetty.xml /etc/solr/solr-jetty.xml
# Update the dovecot plugin configuration # Update the dovecot plugin configuration
# #
# Break-imap-search makes search work the way users expect, rather than the way # Break-imap-search makes search work the way users expect, rather than the way
@ -96,7 +87,7 @@ cat > /etc/dovecot/conf.d/90-plugin-fts.conf << EOF;
plugin { plugin {
fts = solr fts = solr
fts_autoindex = yes fts_autoindex = yes
fts_solr = break-imap-search url=http://127.0.0.1:8983/solr/ fts_solr = url=http://127.0.0.1:8983/solr/dovecot
} }
EOF EOF
@ -105,20 +96,21 @@ hide_output install -m 755 conf/cron/miab_dovecot /etc/cron.daily/
hide_output install -m 644 conf/cron/miab_solr /etc/cron.d/ hide_output install -m 644 conf/cron/miab_solr /etc/cron.d/
# Initialize solr dovecot instance # Initialize solr dovecot instance
if [ ! -d "/var/sorl/data/dovecot" ]; then if [ ! -d "/var/solr/data/dovecot" ]; then
# Starting solr might take a while
echo "Starting solr..."
hide_output systemctl restart solr.service
sudo -u solr /usr/local/lib/solr/bin/solr create -c dovecot sudo -u solr /usr/local/lib/solr/bin/solr create -c dovecot
rm -f /var/solr/data/dovecot/conf/schema.xml rm -f /var/solr/data/dovecot/conf/schema.xml
rm -f /var/solr/data/dovecot/conf/managed-schema rm -f /var/solr/data/dovecot/conf/managed-schema
rm -f /var/solr/data/dovecot/conf/solrconfig.xml rm -f /var/solr/data/dovecot/conf/solrconfig.xml
cp -f conf/solr/solr-config-7.7.0.xml /var/solr/data/dovecot/conf/solrconfig.xml cp -f conf/solr/solr-config-7.7.0.xml /var/solr/data/dovecot/conf/solrconfig.xml
cp -f conf/solr/solr-schema-7.7.0.xml /var/solr/data/dovecot/conf/schema.xml cp -f conf/solr/solr-schema-7.7.0.xml /var/solr/data/dovecot/conf/schema.xml
chown -R solr:solr /var/solr/data/dovecot/*
fi fi
# TODO: add security
#SOLR_IP_WHITELIST="127.0.0.1, [::1]"
# Create new rsyslog config for solr # Create new rsyslog config for solr
# TODO check programname
cat > /etc/rsyslog.d/10-solr.conf <<EOF cat > /etc/rsyslog.d/10-solr.conf <<EOF
# Send solr messages to solr-console.log when using systemd # Send solr messages to solr-console.log when using systemd
:programname, startswith, "solr" { :programname, startswith, "solr" {
@ -131,19 +123,22 @@ EOF
cat > /etc/logrotate.d/solr <<EOF cat > /etc/logrotate.d/solr <<EOF
/var/log/solr.log { /var/log/solr.log {
rotate 14 rotate 7
daily daily
missingok missingok
notifempty notifempty
compress compress
delaycompress delaycompress
create 640 solr adm create 640 syslog adm
} }
EOF EOF
# Restart services to reload solr schema, dovecot plugins and rsyslog changes # Restart services to reload solr schema, dovecot plugins and rsyslog changes
restart_service dovecot restart_service dovecot
restart_service rsyslog restart_service rsyslog
# Restarting solr might take a while
echo "Restarting solr"
hide_output systemctl restart solr.service hide_output systemctl restart solr.service
# Kickoff building the index # Kickoff building the index