[sword-devel] daemon wanted, willing to pay reasonable fee
Karl Kleinpaste
karl at kleinpaste.org
Mon Dec 31 06:44:06 MST 2007
Embellish to taste.
But somebody just tell me why diatheke doesn't generate output when run
from the socket -- works fine at the terminal.
/etc/xinetd.d/sword:
service sword
{
disable = no
port = 22222
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/local/bin/SwordDaemon
type = unlisted
}
/usr/local/bin/SwordDaemon:
#!/bin/bash
#
# xinetd-based reading of commands for Sword response.
#
# Add CR to IFS because such access routinely includes CRLF.
export IFS="$IFS
"
max=10
format=plain
dfltModule="NET"
dfltVerse="Genesis 1:1"
dfltType="multiword"
dfltSearch="Jesus Christ"
options="nmfhx"
#
while read -t 15 command stuff ; do
#echo -n "$command" | od -c
#echo -n "$stuff" | od -c
case "$command" in
quit|q|QUIT|Q)
exit 0
;;
options|o|OPTIONS|O)
options="$stuff"
;;
*)
echo "$stuff" |
while read module searchtype key ; do
case "$command" in
cite|c|CITE|C)
if [ "$module" = "" ] ; then
module="$dfltModule"
echo Module defaulting to "$module".
fi
key="$searchtype $key" # amalgamate
if [ "$key" = "" ] ; then
key="$dfltVerse"
echo Key defaulting to "$key".
fi
diatheke -b "$module" -f "$format" -o "$options" -m "$max" -k "$key" |
sed -e '/^[ \t]*$/d' -e '/^(.*)$/d'
;;
search|s|SEARCH|S)
if [ "$module" = "" ] ; then
module="$dfltModule"
echo Module defaulting to "$module".
fi
if [ "$searchtype" = "" ] ; then
searchtype="$dfltType"
echo SearchType defaulting to "$searchtype".
fi
if [ "$key" = "" ] ; then
key="$dfltSearch"
echo Key defaulting to "$key".
fi
diatheke -b "$module" -f $format -o "$options" -m $max -s "$searchtype" -k "$key" |
sed -e 's/^Verses containing ".*"-- //'
;;
*)
echo SwordDaemon diatheke listener:
echo - usage: this message
echo - quit: exit
echo - cite: ModuleName VerseKey
echo - search: ModuleName SearchType SearchKey
echo - options: NewOptionString
echo defaults:
echo ModuleName - "$dfltModule"
echo VerseKey - "$dfltVerse"
echo SearchType - "$dfltType"
echo SearchKey - "$dfltSearch"
echo current display options - "$options"
;;
esac
done
;;
esac
done
More information about the sword-devel
mailing list