69 lines
2.4 KiB
Bash
69 lines
2.4 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
VOLUME_HOME="/var/lib/sphinxsearch"
|
||
|
|
||
|
# --- Configure
|
||
|
if [[ ! -f sphinx.conf ]]; then
|
||
|
touch sphinx.init.conf
|
||
|
touch sphinx.conf
|
||
|
|
||
|
if [ ${INDEX_ACT} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/act.conf >> sphinx.init.conf
|
||
|
cat /home/sdsphinx/config/act.conf >> sphinx.conf
|
||
|
fi
|
||
|
if [ ${INDEX_CIBLAGE} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/ciblage.conf >> sphinx.init.conf
|
||
|
if [ ${SLAVE} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/ciblage.conf >> sphinx.conf
|
||
|
else
|
||
|
cat /home/sdsphinx/config/ciblagetmp.conf >> sphinx.conf
|
||
|
fi
|
||
|
fi
|
||
|
if [ ${INDEX_DIR} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/dir.conf >> sphinx.init.conf
|
||
|
if [ ${SLAVE} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/dir.conf >> sphinx.conf
|
||
|
else
|
||
|
cat /home/sdsphinx/config/dirtmp.conf >> sphinx.conf
|
||
|
fi
|
||
|
fi
|
||
|
if [ ${INDEX_ENT} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/ent.conf >> sphinx.init.conf
|
||
|
if [ ${SLAVE} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/ent.conf >> sphinx.conf
|
||
|
else
|
||
|
cat /home/sdsphinx/config/enttmp.conf >> sphinx.conf
|
||
|
fi
|
||
|
cp -v /home/sdsphinx/config/stopwords-ent.txt /etc/sphinxsearch/
|
||
|
cp -v /home/sdsphinx/config/wordforms-ent.txt /etc/sphinxsearch/
|
||
|
fi
|
||
|
if [ ${INDEX_HISTO} -eq 1 ]; then
|
||
|
cat /home/sdsphinx/config/histo.conf >> sphinx.init.conf
|
||
|
cat /home/sdsphinx/config/histo.conf >> sphinx.conf
|
||
|
fi
|
||
|
|
||
|
# --- Assign vars
|
||
|
sed -i -e "s/sql_host = ENV_MYSQLHOST/sql_host = $MYSQL_HOST/" sphinx*.conf
|
||
|
sed -i -e "s/sql_user = ENV_MYSQLUSER/sql_user = $MYSQL_USER/" sphinx*.conf
|
||
|
sed -i -e "s/sql_pass = ENV_MYSQLPASS/sql_pass = $MYSQL_PASS/" sphinx*.conf
|
||
|
|
||
|
sed -i -e "s/MYSQL_HOST=ENV_MYSQLHOST/MYSQL_HOST=$MYSQL_HOST/" /home/sdsphinx/indexer/*.sh
|
||
|
sed -i -e "s/MYSQL_USER=ENV_MYSQLUSER/MYSQL_USER=$MYSQL_USER/" /home/sdsphinx/indexer/*.sh
|
||
|
sed -i -e "s/MYSQL_PASS=ENV_MYSQLPASS/MYSQL_PASS=$MYSQL_PASS/" /home/sdsphinx/indexer/*.sh
|
||
|
|
||
|
cat sphinx.init.conf /home/sdsphinx/config/sphinx.conf > /etc/sphinxsearch/sphinx.init.conf
|
||
|
cat sphinx.conf /home/sdsphinx/config/sphinx.conf > /etc/sphinxsearch/sphinx.conf
|
||
|
fi
|
||
|
|
||
|
# --- Init
|
||
|
if [[ ! -d $VOLUME_HOME/idx ]]; then
|
||
|
echo "=> An empty or uninitialized SPHINXSEARCH volume is detected in $VOLUME_HOME"
|
||
|
mkdir -p /var/lib/sphinxsearch/log && mkdir -p /var/lib/sphinxsearch/idx
|
||
|
echo "=> Creation index ..."
|
||
|
/usr/bin/indexer --config /etc/sphinxsearch/sphinx.init.conf --all
|
||
|
echo "=> Done!"
|
||
|
else
|
||
|
echo "=> Using an existing volume of SphinxSearch"
|
||
|
fi
|
||
|
|
||
|
exec /usr/bin/searchd --nodetach
|