mirror of the now-defunct rocklinux.org
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.

115 lines
3.2 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/misc/dictd/mod_dictd.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  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; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. #
  23. #
  24. # [MAIN] 80 dictd Configuration for dictionary server
  25. conf=/etc/dictd.conf
  26. list_dictionaries () {
  27. ds=""
  28. for i in $( ls /usr/share/dictd/*.index )
  29. do
  30. ds="$ds `basename $i .index`"
  31. done
  32. }
  33. select_dict() {
  34. if grep "database[[:space:]]\+\"$1\"" $conf 2>&1 >/dev/null
  35. then
  36. # delete entry if it is not for select all
  37. if [ "$2" != "1" ] ; then
  38. perl -i -00 -p -e"s/database\s+\"$1\"\s+\{.+\}//s" $conf
  39. fi
  40. else
  41. # set entry if it is not in unselect all mode
  42. if [ "$2" != "0" ] ; then
  43. cat <<MSG >>$conf
  44. database "$1"
  45. {
  46. data "/usr/share/dictd/$1.dict.dz"
  47. index "/usr/share/dictd/$1.index"
  48. }
  49. MSG
  50. fi
  51. fi
  52. }
  53. select_dictionaries() {
  54. while
  55. cmd="gui_menu dictd 'Select the dictionaries which"
  56. 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
  61. for dic in $ds
  62. do
  63. if grep "database[[:space:]]\+\"$dic\"" $conf 2>&1 >/dev/null
  64. then
  65. dics=$(printf "%-10sOK" "$dic")
  66. else
  67. dics=$(printf "%-10s--" "$dic")
  68. fi
  69. cmd="$cmd '$dics' 'select_dict \"$dic\"'"
  70. done
  71. eval $cmd
  72. do : ; done
  73. }
  74. all_dictionaries() {
  75. list_dictionaries
  76. for dic in $ds
  77. do
  78. select_dict "$dic" 1
  79. done
  80. }
  81. deselect_all() {
  82. list_dictionaries
  83. for dic in $ds
  84. do
  85. select_dict "$dic" 0
  86. done
  87. }
  88. main() {
  89. while
  90. cmd="gui_menu dictd 'Configuration for dictionary server' "
  91. list_dictionaries
  92. if [ -z "$ds" ] ; then gui_message \
  93. "There is no dictionary installed. Please install one."
  94. return ; fi
  95. cmd="$cmd 'Select dictionaries' 'select_dictionaries'"
  96. cmd="$cmd 'Select all installed dictionaries' 'all_dictionaries'"
  97. cmd="$cmd 'Deselect all dictionaries' 'deselect_all'"
  98. cmd="$cmd 'Edit $conf' 'gui_edit DICTD $conf'"
  99. eval $cmd
  100. do : ; done
  101. }