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.

228 lines
7.9 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../stone/stone_mod_general.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 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. # [MAIN] 10 general,main Various general system configurations
  17. # [SETUP] 10 general set_tmarea
  18. # [SETUP] 15 general set_dtime
  19. # [SETUP] 20 general set_locale
  20. # # [SETUP] 30 general set_vcfont
  21. set_keymap() {
  22. keymap=$(ls -l /etc/default.keymap 2> /dev/null | sed 's,.*/,,')
  23. [ -z "$keymap" ] && keymap="none" ; keymap="${keymap%.map.gz}"
  24. # ReneR: Attention: althought this reads i386, this is nowadays valid
  25. # for all (? - at least also on PowerPC where this was a long ugly
  26. # bug in ROCK times) - the input layer does pass "unified" events ...
  27. mapdir="`echo /usr/share/kbd/keymaps/i386`"
  28. cmd="gui_menu 'general_keymap' 'Select one of the following keyboard mappings.'"
  29. if [ "$keymap" != none ]; then
  30. cmd="$cmd 'Current: $keymap' 'loadkeys defkeymap'"
  31. fi
  32. cmd="$cmd 'none (kernel defaults)' 'rm -f /etc/default.keymap ; loadkeys defkeymap'"
  33. cmd="$cmd $( find $mapdir -type f ! -path '*/include/*' -name '*.map.gz' -printf '%P\n' | sed 's,\(.*\)/\(.*\).map.gz$,"\2 (\1)" "ln -sf '$mapdir'/& /etc/default.keymap ; loadkeys \2",' | expand -t30 | sort | tr '\n' ' ')"
  34. eval "$cmd"
  35. }
  36. set_vcfont() {
  37. vcfont=$(ls -l /etc/default.vcfont 2> /dev/null | sed 's,.*/,,')
  38. if [ -z "$vcfont" ] ; then vcfont="none"
  39. else vcfont="`echo $vcfont | sed -e "s,\.\(fnt\|psf.*\)\.gz$,,"`" ; fi
  40. fontdir="/usr/share/kbd/consolefonts"
  41. cmd="gui_menu 'general_vcfont' 'Select one of the following console fonts.'"
  42. if [ "$vcfont" != none ]; then
  43. cmd="$cmd 'Current: $vcfont' 'setfont'"
  44. fi
  45. cmd="$cmd 'none (kernel defaults)' 'rm -f /etc/default.vcfont ; setfont'"
  46. cmd="$cmd $( find $fontdir -type f \( -name '*.fnt.gz' -or -name '*.psf*.gz' \) -printf '%P\n' | sed 's,\(.*\).\(fnt\|psf.*\)\.gz$,"\1" "ln -sf '$fontdir'/& /etc/default.vcfont ; setfont \1",' | expand -t30 | sort | tr '\n' ' ')"
  47. eval "$cmd"
  48. }
  49. store_kbd(){
  50. if [ -f /etc/conf/kbd ] ; then
  51. sed -e "s/kbd_rate=.*/kbd_rate=$kbd_rate/" \
  52. -e "s/kbd_delay=.*/kbd_delay=$kbd_delay/" < /etc/conf/kbd \
  53. > /etc/conf/kbd.tmp
  54. grep -q kbd_rate= /etc/conf/kbd.tmp || echo kbd_rate=$kbd_rate \
  55. >> /etc/conf/kbd.tmp
  56. grep -q kbd_delay= /etc/conf/kbd.tmp || echo kbd_delay=$kbd_delay \
  57. >> /etc/conf/kbd.tmp
  58. mv /etc/conf/kbd.tmp /etc/conf/kbd
  59. else
  60. echo -e "kbd_rate=$kbd_rate\nkbd_delay=$kbd_delay\n" \
  61. > /etc/conf/kbd
  62. fi
  63. [ "$kbd_rate" -a "$kbd_delay" ] && kbdrate -r $kbd_rate -d $kbd_delay
  64. }
  65. set_kbd_rate() {
  66. gui_input "Set new console keyboard auto-repeat rate" \
  67. "$kbd_rate" "kbd_rate"
  68. store_kbd
  69. }
  70. set_kbd_delay() {
  71. gui_input "Set new console keyboard auto-repeat delay" \
  72. "$kbd_delay" "kbd_delay"
  73. store_kbd
  74. }
  75. store_con(){
  76. if [ -f /etc/conf/console ] ; then
  77. sed -e "s/con_term=.*/con_term=$con_term/" \
  78. -e "s/con_blank=.*/con_blank=$con_blank/" \
  79. < /etc/conf/console > /etc/conf/console.tmp
  80. grep -q con_term= /etc/conf/console.tmp || \
  81. echo con_term=$con_term >> /etc/conf/console.tmp
  82. grep -q con_blank= /etc/conf/console.tmp || \
  83. echo con_blank=$con_blank >> /etc/conf/console.tmp
  84. mv /etc/conf/console.tmp /etc/conf/console
  85. else
  86. echo -e "con_term=$con_term\ncon_blank=$con_blank\n" \
  87. > /etc/conf/console
  88. fi
  89. [ "$con_term" -a "$con_blank" ] && \
  90. setterm -term $con_term -blank $con_blank > /dev/console
  91. }
  92. set_con_term() {
  93. gui_input "Set new console screen terminal type" \
  94. "$con_term" "con_term"
  95. store_con
  96. }
  97. set_con_blank() {
  98. gui_input "Set new console screen blank interval" \
  99. "$con_blank" "con_blank"
  100. store_con
  101. }
  102. set_tmzone() {
  103. tz="$( ls -l /etc/localtime | cut -f8 -d/ )"
  104. cmd="gui_menu 'general_tmzone' 'Select one of the following time zones.'"
  105. if [ -n "$tz" -a -f ../usr/share/zoneinfo/$1/$tz ]; then
  106. cmd="$cmd 'Current: $tz' 'ln -sf ../usr/share/zoneinfo/$1/$tz \
  107. /etc/localtime'"
  108. fi
  109. cmd="$cmd $( grep "$1/" /usr/share/zoneinfo/zone.tab | cut -f3 | \
  110. cut -f2 -d/ | sort -u | tr '\n' ' ' | sed 's,[^ ]\+,& '`
  111. `'"ln -sf ../usr/share/zoneinfo/$1/& /etc/localtime",g' )"
  112. eval "$cmd"
  113. }
  114. set_tmarea() {
  115. tz="$( ls -l /etc/localtime | cut -f7 -d/ )"
  116. cmd="gui_menu 'general_tmarea' 'Select one of the following time areas.'"
  117. cmd="$cmd 'Current: $tz' 'if set_tmzone $tz ; then tzset=1 ; fi'"
  118. cmd="$cmd $( grep '^[^#]' /usr/share/zoneinfo/zone.tab | cut -f3 | \
  119. cut -f1 -d/ | sort -u | tr '\n' ' ' | sed 's,[^ ]\+,& '`
  120. `'"if set_tmzone & ; then tzset=1 ; fi",g' )"
  121. tzset=0
  122. while eval "$cmd" && [ $tzset = 0 ] ; do : ; done
  123. }
  124. set_dtime() {
  125. local set=0
  126. while [ $set = 0 ]; do
  127. dtime="`date '+%m-%d %H:%M %Y'`" ; newdtime="$dtime"
  128. [ -f /etc/conf/clock ] && . /etc/conf/clock
  129. [ "$clock_tz" != localtime ] && clock_tz=utc
  130. gui_input "Set new date and time (MM-DD hh:mm YYYY, $clock_tz)" \
  131. "$dtime" "newdtime"
  132. if [ "$dtime" != "$newdtime" ] ; then
  133. echo "Setting new date and time ($newdtime) ..."
  134. if ! date "$( echo $newdtime | sed 's,[^0-9],,g' )"; then
  135. gui_message "Error setting time, invalid timespec?"
  136. else
  137. set=1
  138. fi
  139. hwclock --systohc --$clock_tz
  140. else
  141. set=1
  142. fi
  143. done
  144. }
  145. set_locale_sub() {
  146. rm -f /etc/profile.d/locale
  147. [ "$1" != "none" ] && echo "export LANG='$1'" > /etc/profile.d/locale
  148. }
  149. set_locale() {
  150. unset LANG ; [ -f /etc/profile.d/locale ] && . /etc/profile.d/locale
  151. locale="${LANG:-none}" ; cmd="gui_menu 'general_locale' 'Select one of the following locales.'"
  152. if [ "$locale" != none ]; then
  153. title=$(grep ^title /usr/share/i18n/locales/$locale | sed \
  154. -e 's,.*"\(.*\)".*,\1,g' -e "s,',�,g")
  155. x="$( echo -e "Current: ${title:0:41}\t$locale" | expand -t52 )"
  156. cmd="$cmd '$x' 'true'"
  157. fi
  158. x="$( echo -e "none\tnone" | expand -t52 )"
  159. cmd="$cmd '$x' 'set_locale_sub none'"
  160. x="$( echo -e "POSIX\tC" | expand -t52 )"
  161. cmd="$cmd '$x' 'set_locale_sub C' $(
  162. grep -H ^title /usr/share/i18n/locales/* | sed \
  163. -e 's,.*/\(.*\):.*"\(.*\)",\1\t\2,g' \
  164. -e "s,',�,g" | while read key title; do
  165. echo "'${title:0:50} $key' 'set_locale_sub $key'" | expand -t53 | tr '\n' ' '
  166. done
  167. )"
  168. eval "$cmd"
  169. }
  170. main() {
  171. while
  172. unset LANG ; [ -f /etc/profile.d/locale ] && . /etc/profile.d/locale
  173. locale="${LANG:-none}" ; tz="$( ls -l /etc/localtime | cut -f7- -d/ )"
  174. keymap=$(ls -l /etc/default.keymap 2> /dev/null | sed 's,.*/,,')
  175. [ "$keymap" ] || keymap="none" ; keymap="${keymap%.map.gz}"
  176. vcfont=$(ls -l /etc/default.vcfont 2> /dev/null | sed 's,.*/,,')
  177. if [ -z "$vcfont" ] ; then vcfont="none"
  178. else vcfont="`echo $vcfont | sed -e "s,\.\(fnt\|psf.*\)\.gz$,,"`" ; fi
  179. dtime="`date '+%m-%d %H:%M %Y'`"
  180. [ -f /etc/conf/kbd ] && . /etc/conf/kbd
  181. [ "$kbd_rate" ] || kbd_rate=30
  182. [ "$kbd_delay" ] || kbd_delay=250
  183. [ -f /etc/conf/console ] && . /etc/conf/console
  184. [ "$con_term" ] || con_term=linux
  185. [ "$con_blank" ] || con_blank=0
  186. gui_menu general 'Various general system configurations' \
  187. "Set console keyboard mapping ....... $keymap" "set_keymap" \
  188. "Set console screen font ............ $vcfont" "set_vcfont" \
  189. "Set system-wide time zone .......... $tz" "set_tmarea" \
  190. "Set date and time (utc/localtime) .. $dtime" "set_dtime" \
  191. "Set system-wide locale (language) .. $locale" "set_locale" \
  192. "Set console keyboard repeat rate ... $kbd_rate" "set_kbd_rate" \
  193. "Set console keyboard repeat delay .. $kbd_delay" "set_kbd_delay" \
  194. "Set console screen terminal type ... $con_term" "set_con_term" \
  195. "Set console screen blank interval .. $con_blank" "set_con_blank" \
  196. "Run the (daily) 'cron.run' script now" "cron.run"
  197. do : ; done
  198. }