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.

109 lines
2.9 KiB

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