* updated knights (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / package / dictionary / dictd / stone_mod_dictd.sh
blob3a14797256d16ee70353c859d69546844eeb081c
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../dictd/mod_dictd.sh
5 # Copyright (C) 2004 - 2006 The T2 SDE Project
6 # Copyright (C) 1998 - 2004 ROCK Linux Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
18 # [MAIN] 80 dictd Configuration for dictionary server
21 conf=/etc/dictd.conf
23 list_dictionaries () {
24 ds=""
25 for i in $( ls /usr/share/dictd/*.index )
27 ds="$ds `basename $i .index`"
28 done
31 select_dict() {
32 if grep "database[[:space:]]\+\"$1\"" $conf 2>&1 >/dev/null
33 then
34 # delete entry if it is not for select all
35 if [ "$2" != "1" ] ; then
36 perl -i -00 -p -e"s/database\s+\"$1\"\s+\{.+\}//s" $conf
38 else
39 # set entry if it is not in unselect all mode
40 if [ "$2" != "0" ] ; then
41 cat <<MSG >>$conf
42 database "$1"
44 data "/usr/share/dictd/$1.dict.dz"
45 index "/usr/share/dictd/$1.index"
47 MSG
49 fi
52 select_dictionaries() {
53 while
54 cmd="gui_menu dictd 'Select the dictionaries which"
55 cmd="$cmd will be served by dictd.'"
57 list_dictionaries
58 if [ -z "$ds" ] ; then gui_message \
59 "Stone can not find any dictionary. Please install one!"
60 return; fi
62 for dic in $ds
64 if grep "database[[:space:]]\+\"$dic\"" $conf 2>&1 >/dev/null
65 then
66 dics=$(printf "%-10sOK" "$dic")
67 else
68 dics=$(printf "%-10s--" "$dic")
69 fi
70 cmd="$cmd '$dics' 'select_dict \"$dic\"'"
71 done
72 eval $cmd
73 do : ; done
76 all_dictionaries() {
77 list_dictionaries
78 for dic in $ds
80 select_dict "$dic" 1
81 done
84 deselect_all() {
85 list_dictionaries
86 for dic in $ds
88 select_dict "$dic" 0
89 done
92 main() {
93 while
95 cmd="gui_menu dictd 'Configuration for dictionary server' "
96 list_dictionaries
97 if [ -z "$ds" ] ; then gui_message \
98 "There is no dictionary installed. Please install one."
99 return ; fi
101 cmd="$cmd 'Select dictionaries' 'select_dictionaries'"
102 cmd="$cmd 'Select all installed dictionaries' 'all_dictionaries'"
103 cmd="$cmd 'Deselect all dictionaries' 'deselect_all'"
104 cmd="$cmd 'Edit $conf' 'gui_edit DICTD $conf'"
105 eval $cmd
106 do : ; done