5
# Copyright (C) 2008 Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
9
# Permission is hereby granted, free of charge, to any person obtaining a copy
10
# of this software and associated documentation files (the "Software"), to deal
11
# in the Software without restriction, including without limitation the rights
12
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
# copies of the Software, and to permit persons to whom the Software is
14
# furnished to do so, subject to the following conditions:
16
# The above copyright notice and this permission notice shall be included in all
17
# copies or substantial portions of the Software.
19
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
# Get the config directory
30
if [ -n "${BEAGLE_HOME}" ]; then
31
CONFDIR="${BEAGLE_HOME}/.beagle/config"
32
elif [ -n "${BEAGLE_STORAGE}" ]; then
33
CONFDIR="${BEAGLE_STORAGE}/config"
34
elif [ -n "${BEAGLE_CONF_DIR}" ]; then
35
CONFDIR="${BEAGLE_CONF_DIR}"
40
CONFFILE="${CONFDIR}/blocate.conf"
42
if ! [ -e "${CONFFILE}" ]; then
43
echo "Error: config file \"${CONFFILE}\" does not exist"
47
# Read config settings
51
# Use here-documents for great justice.
53
blocate: Special locate powered by Beagle
54
Web page: http://www.beagle-project.org/
55
Usage: blocate [OPTIONS] <query string>
58
-d, --database NAME query backend given by NAME instead of default
59
-d, --database PATH query backend given by PATH instead of default
60
Both of the above options can be repeated.
61
If they are specified then the default backends are ignored.
62
Default backends are specified in ~/.beagle/config/blocate.conf or /etc/beagle/blocate.conf
66
# While we still have arguments..
67
while [ -n "${1}" ]; do
70
if [[ "${arg}" == "-h" || "${arg}" == "--help" ]]; then
73
elif [[ "${arg}" == "-d" || "${arg}" == "--database" ]]; then
74
# Take in it's value; shift
78
if [[ "${argvalue}" =~ "/" ]]; then
79
# If the dir is not an absolute path
80
if [ -n "${argvalue%%/*}" ]; then
81
echo "Error: \"${argvalue}\" - relative paths not allowed"
84
# If absolute path and DNE
85
if ! [ -d "${argvalue}" ]; then
86
echo "Error: directory \"${argvalue}\" does not exist"
90
arg="--add-static-backend ${argvalue}"
92
arg="--backend ${argvalue}"
95
OPTS=("${OPTS[@]}" "${arg}")
98
# If you give -d, --database as args, the entire config is ignored
99
if [ "$ignore_config" != "true" ]; then
100
for i in ${STATIC_INDEXES}; do
101
OPTS=("${OPTS[@]}" "--add-static-backend" "${i}")
103
for i in ${BACKENDS}; do
104
OPTS=("${OPTS[@]}" "--backend" "${i}")
108
# We add "--backend none" else it'll query all backends if there are no --backend params
109
beagle-static-query ${OPTS[@]} --backend none