forked from gillbeits/sphinxsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
66 lines (58 loc) · 1.72 KB
/
entrypoint.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
#!/bin/bash
set -e
DOCKER_HOST=`/sbin/ip route|awk '/default/ { print $3 }'`
echo "${DOCKER_HOST} ${HOST_IP}" >> /etc/hosts
if [ ${RSYNC} = 'YES' ]; then
cat <<EOF > /etc/rsyncd.conf
# Rsync config for SphinxSearch Docker Container
uid = ${RSYNC_OWNER}
gid = ${RSYNC_GROUP}
use chroot = yes
pid file = /var/run/rsyncd.pid
log file = /dev/stdout
[sphinx]
hosts deny = *
hosts allow = ${RSYNC_ALLOW}
read only = ${RSYNC_READONLY}
path = ${RSYNC_VOLUME}
comment = docker sphinx data directory
EOF
/usr/bin/rsync --daemon --config /etc/rsyncd.conf
fi
if [ "$1" = 'sphinx' ]; then
chown -R sphinx:sphinx /var/lib/sphinx /var/log/sphinx
echo "Start Cron Daemon"
/usr/sbin/crond -n -x misc 2>&1 | awk '{ print strftime("%a %b %d %T %Y"), $0; fflush() }' >> /var/log/sphinx/cron &
if [ "$2" = 'indexer' ] && [ ! -e /tmp/sphinx.index ]; then
shift
shift
indexes=$@
if [ -z "$1" ]; then
indexes='--all'
fi
echo "Start Sphinxsearch Indexer for \"$indexes\" indexes"
su - sphinx -c "/usr/bin/indexer $indexes" 2>&1 | tee /var/log/sphinx/indexer.log
echo "Finish Sphinxsearch Indexer for \"$indexes\" indexes"
echo "$indexes" > /tmp/sphinx.index
fi
echo "Starting Sphinx"
/usr/bin/searchd -c /etc/sphinx/sphinx.conf --nodetach
elif [ "$1" = 'indexer' ]; then
shift
indexes=$@
if [ -z "$1" ]; then
indexes='--all'
fi
echo "Start Sphinxsearch Indexer for \"$indexes\" indexes"
su - sphinx -c "/usr/bin/indexer --rotate $indexes"
elif [ "$1" = 'crontab' ]; then
crontab -e -u sphinx
elif [ "$1" = 'console' ]; then
mysql -h ${SPHINX_PORT_9306_TCP_ADDR} -P ${SPHINX_PORT_9306_TCP_PORT}
elif [ "$1" = 'editconfig' ]; then
vim /etc/sphinx/sphinx.conf
elif [ "$1" = 'log' ]; then
tail -f /var/log/sphinx/*
else
exec "$@"
fi