OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.9 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../dictd/stone_mod_dictd.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2004 Clifford Wolf
  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 ---
  15. #
  16. #
  17. # [MAIN] 80 dictd Configuration for dictionary server
  18. conf=/etc/dictd.conf
  19. list_dictionaries () {
  20. ds=""
  21. for i in $( ls /usr/share/dictd/*.index )
  22. do
  23. ds="$ds `basename $i .index`"
  24. done
  25. }
  26. select_dict() {
  27. if grep "database[[:space:]]\+\"$1\"" $conf 2>&1 >/dev/null
  28. then
  29. # delete entry if it is not for select all
  30. if [ "$2" != "1" ] ; then
  31. perl -i -00 -p -e"s/database\s+\"$1\"\s+\{.+\}//s" $conf
  32. fi
  33. else
  34. # set entry if it is not in unselect all mode
  35. if [ "$2" != "0" ] ; then
  36. cat <<MSG >>$conf
  37. database "$1"
  38. {
  39. data "/usr/share/dictd/$1.dict.dz"
  40. index "/usr/share/dictd/$1.index"
  41. }
  42. MSG
  43. fi
  44. fi
  45. }
  46. select_dictionaries() {
  47. while
  48. cmd="gui_menu dictd 'Select the dictionaries which"
  49. cmd="$cmd will be served by dictd.'"
  50. list_dictionaries
  51. if [ -z "$ds" ] ; then gui_message \
  52. "Stone can not find any dictionary. Please install one!"
  53. return; fi
  54. for dic in $ds
  55. do
  56. if grep "database[[:space:]]\+\"$dic\"" $conf 2>&1 >/dev/null
  57. then
  58. dics=$(printf "%-10sOK" "$dic")
  59. else
  60. dics=$(printf "%-10s--" "$dic")
  61. fi
  62. cmd="$cmd '$dics' 'select_dict \"$dic\"'"
  63. done
  64. eval $cmd
  65. do : ; done
  66. }
  67. all_dictionaries() {
  68. list_dictionaries
  69. for dic in $ds
  70. do
  71. select_dict "$dic" 1
  72. done
  73. }
  74. deselect_all() {
  75. list_dictionaries
  76. for dic in $ds
  77. do
  78. select_dict "$dic" 0
  79. done
  80. }
  81. main() {
  82. while
  83. cmd="gui_menu dictd 'Configuration for dictionary server' "
  84. list_dictionaries
  85. if [ -z "$ds" ] ; then gui_message \
  86. "There is no dictionary installed. Please install one."
  87. return ; fi
  88. cmd="$cmd 'Select dictionaries' 'select_dictionaries'"
  89. cmd="$cmd 'Select all installed dictionaries' 'all_dictionaries'"
  90. cmd="$cmd 'Deselect all dictionaries' 'deselect_all'"
  91. cmd="$cmd 'Edit $conf' 'gui_edit DICTD $conf'"
  92. eval $cmd
  93. do : ; done
  94. }