[python] Updated (2.4.4 -> 2.4.5)
[opensde-package-nopast.git] / dictionary / dictd / stone_mod_dictd.sh
blob60f6855d0288b693f866184bb9430563eb7ca2b7
1 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # Filename: package/.../dictd/stone_mod_dictd.sh
5 # Copyright (C) 2008 The OpenSDE Project
6 # Copyright (C) 2004 - 2006 The T2 SDE Project
7 # Copyright (C) 1998 - 2004 Clifford Wolf
9 # More information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- SDE-COPYRIGHT-NOTE-END ---
19 # [MAIN] 80 dictd Configuration for dictionary server
22 conf=/etc/dictd.conf
24 list_dictionaries () {
25 ds=
26 for i in $( ls /usr/share/dictd/*.index )
28 ds="$ds `basename $i .index`"
29 done
32 select_dict() {
33 if grep "database[[:space:]]\+\"$1\"" $conf 2>&1 >/dev/null
34 then
35 # delete entry if it is not for select all
36 if [ "$2" != "1" ] ; then
37 perl -i -00 -p -e"s/database\s+\"$1\"\s+\{.+\}//s" $conf
39 else
40 # set entry if it is not in unselect all mode
41 if [ "$2" != "0" ] ; then
42 cat <<MSG >>$conf
43 database "$1"
45 data "/usr/share/dictd/$1.dict.dz"
46 index "/usr/share/dictd/$1.index"
48 MSG
53 select_dictionaries() {
54 while
55 cmd="gui_menu dictd 'Select the dictionaries which"
56 cmd="$cmd will be served by dictd.'"
58 list_dictionaries
59 if [ -z "$ds" ] ; then gui_message \
60 "Stone can not find any dictionary. Please install one!"
61 return; fi
63 for dic in $ds
65 if grep "database[[:space:]]\+\"$dic\"" $conf 2>&1 >/dev/null
66 then
67 dics=$(printf "%-10sOK" "$dic")
68 else
69 dics=$(printf "%-10s--" "$dic")
71 cmd="$cmd '$dics' 'select_dict \"$dic\"'"
72 done
73 eval $cmd
74 do : ; done
77 all_dictionaries() {
78 list_dictionaries
79 for dic in $ds
81 select_dict "$dic" 1
82 done
85 deselect_all() {
86 list_dictionaries
87 for dic in $ds
89 select_dict "$dic" 0
90 done
93 main() {
94 while
96 cmd="gui_menu dictd 'Configuration for dictionary server' "
97 list_dictionaries
98 if [ -z "$ds" ] ; then gui_message \
99 "There is no dictionary installed. Please install one."
100 return ; fi
102 cmd="$cmd 'Select dictionaries' 'select_dictionaries'"
103 cmd="$cmd 'Select all installed dictionaries' 'all_dictionaries'"
104 cmd="$cmd 'Deselect all dictionaries' 'deselect_all'"
105 cmd="$cmd 'Edit $conf' 'gui_edit DICTD $conf'"
106 eval $cmd
107 do : ; done