aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-01-07 12:27:33 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-01-07 12:27:33 +0200
commit8e56ae173e0957615bca5cdc94968fbdff675ec1 (patch)
treedac7e93cf678f90dcaf6919f1e3bf07db6c55d5a
parent1f335a35cab414f09754c6585958cd5cd51df900 (diff)
downloadswis-8e56ae173e0957615bca5cdc94968fbdff675ec1.tar.gz
swis-8e56ae173e0957615bca5cdc94968fbdff675ec1.tar.bz2
Minor changes.
* src/swis.in: Read basic configuration before running the command. * src/swis.conf: Add `backend' statement.
-rw-r--r--src/swis.conf2
-rw-r--r--src/swis.in54
2 files changed, 29 insertions, 27 deletions
diff --git a/src/swis.conf b/src/swis.conf
index 51a40a4..48cc41e 100644
--- a/src/swis.conf
+++ b/src/swis.conf
@@ -23,6 +23,8 @@ full-text yes;
# Set exclude pattern.
exclude "[0-9]+";
+backend mysql;
+
backend-config mysql {
config-file "./myswis.cfg";
config-group "swis";
diff --git a/src/swis.in b/src/swis.in
index 9588409..ac0591e 100644
--- a/src/swis.in
+++ b/src/swis.in
@@ -15,9 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with SWIS. If not, see <http://www.gnu.org/licenses/>.
-CONFIG==SYSCONFDIR=/swis.conf
+SWIS_CONFIG==SYSCONFDIR=/swis.conf
+export SWIS_CONFIG
PATH==LIBEXECDIR=:$PATH
-DEBUG=
+debug=
error() {
echo >&2 "$0: $*"
@@ -34,7 +35,7 @@ die() {
absname() {
case $1 in
/*) echo $1;;
- *) dir=`expr "$CONFIG" : '\(.*\)/.*'`
+ *) dir=`expr "$SWIS_CONFIG" : '\(.*\)/.*'`
if [ -n "$dir" ]; then
echo $dir/$1
else
@@ -45,23 +46,6 @@ absname() {
# dirscan [dir [url]]
dirscan() {
- if [ -r $CONFIG ]; then
- SWIS_CONFIG=$CONFIG
- export SWIS_CONFIG
-
- cfgtool --lint || exit $?
-
- eval `cfgtool --assign directory base-url find-options backend`
-
- if test -z "$backend"; then
- backend=cat
- else
- backend=${backend}-backend
- fi
- else
- die 1 "configuration file $CONFIG does not exist or is unreadable"
- fi
-
file_pattern=`cfgtool file-pattern |
awk '{ if (NR>1) printf(" -or ")
printf("-name '\''%s'\''", $0); }'`
@@ -71,8 +55,8 @@ dirscan() {
fi
# Process arguments
- [ -n "$1" ] && directory=$1
- [ -n "$2" ] && base_url=$2
+ test -n "$1" && directory=$1
+ test -n "$2" && base_url=$2
case $directory in
"") die 1 "Source directory not given"
@@ -102,10 +86,12 @@ cleanup() {
# webcan url
webscan() {
+ test -n "$1" && base_url=$1
+ test -z "$base_url" && die 1 "URL not given"
mkdir $TMPDIR || die "cannot create temporary directory"
trap cleanup 1 2 13 15
- wget -q -r -nH -P$TMPDIR $1
- dirscan $TMPDIR $1
+ wget -q -r -nH -P$TMPDIR $base_url
+ dirscan $TMPDIR $base_url
cleanup
}
@@ -140,15 +126,15 @@ longopt() {
exit 0
;;
d|de|deb|debu|debug)
- [ -z "$DEBUG" ] && DEBUG=-
- DEBUG="${DEBUG}d"
+ [ -z "$debug" ] && debug=-
+ debug="${debug}d"
;;
v|ve|ver|vers|versi|versio|version)
cfgtool --version | sed "s|cfgtool|$0|g"
exit 0
;;
c|co|conf|confi|config)
- CONFIG=$2
+ SWIS_CONFIG=$2
;;
*)
error "unknown long option: --$1"
@@ -187,6 +173,20 @@ done
shift $(($OPTIND - 1))
+if [ -r $SWIS_CONFIG ]; then
+ cfgtool --lint || exit $?
+
+ eval `cfgtool --assign directory base-url find-options backend`
+
+ if test -z "$backend"; then
+ backend=cat
+ else
+ backend=${backend}-backend
+ fi
+else
+ die 1 "configuration file $SWIS_CONFIG does not exist or is unreadable"
+fi
+
if [ $# -eq 0 ]; then
die 1 "command not given"
fi

Return to:

Send suggestions and report system problems to the System administrator.