* mark doxygen CROSS
[t2sde.git] / package / dictionary / dictd / stone_mod_dictd.sh
blobb392ac0ac0a0ed29185e6301786bb6226ea3de04
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/dictd/stone_mod_dictd.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
4 # Copyright (C) 1998 - 2004 ROCK Linux Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
15 # [MAIN] 80 dictd Configuration for dictionary server
18 conf=/etc/dictd.conf
20 list_dictionaries () {
21 ds=""
22 for i in $( ls /usr/share/dictd/*.index )
24 ds="$ds `basename $i .index`"
25 done
28 select_dict() {
29 if grep "database[[:space:]]\+\"$1\"" $conf 2>&1 >/dev/null
30 then
31 # delete entry if it is not for select all
32 if [ "$2" != "1" ]; then
33 perl -i -00 -p -e"s/database\s+\"$1\"\s+\{.+\}//s" $conf
35 else
36 # set entry if it is not in unselect all mode
37 if [ "$2" != "0" ]; then
38 cat <<MSG >>$conf
39 database "$1"
41 data "/usr/share/dictd/$1.dict.dz"
42 index "/usr/share/dictd/$1.index"
44 MSG
49 select_dictionaries() {
50 while
51 cmd="gui_menu dictd 'Select the dictionaries which"
52 cmd="$cmd will be served by dictd.'"
54 list_dictionaries
55 if [ -z "$ds" ]; then gui_message \
56 "Stone can not find any dictionary. Please install one!"
57 return; fi
59 for dic in $ds
61 if grep "database[[:space:]]\+\"$dic\"" $conf 2>&1 >/dev/null
62 then
63 dics=$(printf "%-10sOK" "$dic")
64 else
65 dics=$(printf "%-10s--" "$dic")
67 cmd="$cmd '$dics' 'select_dict \"$dic\"'"
68 done
69 eval $cmd
70 do : ; done
73 all_dictionaries() {
74 list_dictionaries
75 for dic in $ds
77 select_dict "$dic" 1
78 done
81 deselect_all() {
82 list_dictionaries
83 for dic in $ds
85 select_dict "$dic" 0
86 done
89 main() {
90 while
92 cmd="gui_menu dictd 'Configuration for dictionary server' "
93 list_dictionaries
94 if [ -z "$ds" ]; then gui_message \
95 "There is no dictionary installed. Please install one."
96 return; fi
98 cmd="$cmd 'Select dictionaries' 'select_dictionaries'"
99 cmd="$cmd 'Select all installed dictionaries' 'all_dictionaries'"
100 cmd="$cmd 'Deselect all dictionaries' 'deselect_all'"
101 cmd="$cmd 'Edit $conf' 'gui_edit DICTD $conf'"
102 eval $cmd
103 do : ; done