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.

215 lines
7.5 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/base/sysfiles/stone_mod_general.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2003 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. # [MAIN] 10 general,main Various general system configurations
  24. set_keymap() {
  25. keymap=$(ls -l /etc/default.keymap 2> /dev/null | sed 's,.*/,,')
  26. [ -z "$keymap" ] && keymap="none" ; keymap="${keymap%.map.gz}"
  27. case "`uname -m`" in
  28. i*86)
  29. mapdir="`echo /usr/share/kbd/keymaps/i386`"
  30. ;;
  31. ppc)
  32. mapdir="`echo /usr/share/kbd/keymaps/mac`" # ppc is a symlink
  33. ;;
  34. sparc*)
  35. mapdir="`echo /usr/share/kbd/keymaps/sun`"
  36. ;;
  37. *)
  38. gui_message "Can't auto-detect your architecture and so I can't find the right /usr/share/kbd/keymaps sub-directory for your system. Sorry."
  39. return
  40. ;;
  41. esac
  42. cmd="gui_menu 'general_keymap' 'Select one of the"
  43. cmd="$cmd following keyboard mappings. (Current: $keymap)'"
  44. cmd="$cmd 'none (kernel defaults)' 'rm -f /etc/default.keymap ; loadkeys defkeymap'"
  45. 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 -30 | sort | tr '\n' ' ')"
  46. eval "$cmd"
  47. }
  48. set_vcfont() {
  49. vcfont=$(ls -l /etc/default.vcfont 2> /dev/null | sed 's,.*/,,')
  50. if [ -z "$vcfont" ] ; then vcfont="none"
  51. else vcfont="`echo $vcfont | sed -e "s,\.\(fnt\|psf.*\)\.gz$,,"`" ; fi
  52. fontdir="/usr/share/kbd/consolefonts"
  53. cmd="gui_menu 'general_vcfont' 'Select one of the"
  54. cmd="$cmd following console fonts. (Current: $vcfont)'"
  55. cmd="$cmd 'none (kernel defaults)' 'rm -f /etc/default.vcfont ; setfont'"
  56. 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 -30 | sort | tr '\n' ' ')"
  57. eval "$cmd"
  58. }
  59. store_kbd(){
  60. if [ -f /etc/conf/kbd ] ; then
  61. sed -e "s/kbd_rate=.*/kbd_rate=$kbd_rate/" \
  62. -e "s/kbd_delay=.*/kbd_delay=$kbd_delay/" < /etc/conf/kbd \
  63. > /etc/conf/kbd.tmp
  64. grep -q kbd_rate= /etc/conf/kbd.tmp || echo kbd_rate=$kbd_rate \
  65. >> /etc/conf/kbd.tmp
  66. grep -q kbd_delay= /etc/conf/kbd.tmp || echo kbd_delay=$kbd_delay \
  67. >> /etc/conf/kbd.tmp
  68. mv /etc/conf/kbd.tmp /etc/conf/kbd
  69. else
  70. echo -e "kbd_rate=$kbd_rate\nkbd_delay=$kbd_delay\n" \
  71. > /etc/conf/kbd
  72. fi
  73. [ "$kbd_rate" -a "$kbd_delay" ] && kbdrate -r $kbd_rate -d $kbd_delay
  74. }
  75. set_kbd_rate() {
  76. gui_input "Set new console keyboard auto-repeat rate" \
  77. "$kbd_rate" "kbd_rate"
  78. store_kbd
  79. }
  80. set_kbd_delay() {
  81. gui_input "Set new console keyboard auto-repeat delay" \
  82. "$kbd_delay" "kbd_delay"
  83. store_kbd
  84. }
  85. store_con(){
  86. if [ -f /etc/conf/console ] ; then
  87. sed -e "s/con_term=.*/con_term=$con_term/" \
  88. -e "s/con_blank=.*/con_blank=$con_blank/" \
  89. < /etc/conf/console > /etc/conf/console.tmp
  90. grep -q con_term= /etc/conf/console.tmp || \
  91. echo con_term=$con_term >> /etc/conf/console.tmp
  92. grep -q con_blank= /etc/conf/console.tmp || \
  93. echo con_blank=$con_blank >> /etc/conf/console.tmp
  94. mv /etc/conf/console.tmp /etc/conf/console
  95. else
  96. echo -e "con_term=$con_term\ncon_blank=$con_blank\n" \
  97. > /etc/conf/console
  98. fi
  99. [ "$con_term" -a "$con_blank" ] && \
  100. setterm -term $con_term -blank $con_blank > /dev/console
  101. }
  102. set_con_term() {
  103. gui_input "Set new console screen terminal type" \
  104. "$con_term" "con_term"
  105. store_con
  106. }
  107. set_con_blank() {
  108. gui_input "Set new console screen blank interval" \
  109. "$con_blank" "con_blank"
  110. store_con
  111. }
  112. set_tmzone() {
  113. tz="$( ls -l /etc/localtime | cut -f8 -d/ )"
  114. cmd="gui_menu 'general_tmzone' 'Select one of the"
  115. cmd="$cmd following time zones. (Current: $tz)'"
  116. cmd="$cmd $( grep "$1/" /usr/share/zoneinfo/zone.tab | cut -f3 | \
  117. cut -f2 -d/ | sort -u | tr '\n' ' ' | sed 's,[^ ]\+,& '`
  118. `'"ln -sf ../usr/share/zoneinfo/$1/& /etc/localtime",g' )"
  119. eval "$cmd"
  120. }
  121. set_tmarea() {
  122. tz="$( ls -l /etc/localtime | cut -f7 -d/ )"
  123. cmd="gui_menu 'general_tmarea' 'Select one of the"
  124. cmd="$cmd following time areas. (Current: $tz)'"
  125. cmd="$cmd $( grep '^[^#]' /usr/share/zoneinfo/zone.tab | cut -f3 | \
  126. cut -f1 -d/ | sort -u | tr '\n' ' ' | sed 's,[^ ]\+,& '`
  127. `'"if set_tmzone & ; then tzset=1 ; fi",g' )"
  128. tzset=0
  129. while eval "$cmd" && [ $tzset = 0 ] ; do : ; done
  130. }
  131. set_dtime() {
  132. dtime="`date '+%m-%d %H:%M %Y'`" ; newdtime="$dtime"
  133. [ -f /etc/conf/clock ] && . /etc/conf/clock
  134. [ "$clock_tz" != localtime ] && clock_tz=utc
  135. gui_input "Set new date and time (MM-DD hh:mm YYYY, $clock_tz)" \
  136. "$dtime" "newdtime"
  137. if [ "$dtime" != "$newdtime" ] ; then
  138. echo "Setting new date and time ($newdtime) ..."
  139. date "$( echo $newdtime | sed 's,[^0-9],,g' )"
  140. hwclock --systohc --$clock_tz
  141. fi
  142. }
  143. set_locale_sub() {
  144. rm -f /etc/profile.d/locale
  145. [ "$1" != "none" ] && echo "export LANG='$1'" > /etc/profile.d/locale
  146. }
  147. set_locale() {
  148. unset LANG ; [ -f /etc/profile.d/locale ] && . /etc/profile.d/locale
  149. locale="${LANG:-none}" ; cmd="gui_menu 'general_locale' 'Select one of the following locales. (Current: $locale)' 'none' 'set_locale_sub none'"
  150. x="$( echo -e "POSIX\tC" | expand -52 )"
  151. cmd="$cmd '$x' 'set_locale_sub C' $(
  152. grep -H ^title /usr/share/i18n/locales/* 2> /dev/null | \
  153. awk -F '"' '{ sub(".*/", "", $1); sub("[\\.:].*", "", $1); '"
  154. printf \" '%-52s%s' 'set_locale_sub %s'\", \$2, \$1, \$1; }"
  155. )"
  156. eval "$cmd"
  157. }
  158. main() {
  159. while
  160. unset LANG ; [ -f /etc/profile.d/locale ] && . /etc/profile.d/locale
  161. locale="${LANG:-none}" ; tz="$( ls -l /etc/localtime | cut -f7- -d/ )"
  162. keymap=$(ls -l /etc/default.keymap 2> /dev/null | sed 's,.*/,,')
  163. [ "$keymap" ] || keymap="none" ; keymap="${keymap%.map.gz}"
  164. vcfont=$(ls -l /etc/default.vcfont 2> /dev/null | sed 's,.*/,,')
  165. if [ -z "$vcfont" ] ; then vcfont="none"
  166. else vcfont="`echo $vcfont | sed -e "s,\.\(fnt\|psf.*\)\.gz$,,"`" ; fi
  167. dtime="`date '+%m-%d %H:%M %Y'`"
  168. [ -f /etc/conf/kbd ] && . /etc/conf/kbd
  169. [ "$kbd_rate" ] || kbd_rate=30
  170. [ "$kbd_delay" ] || kbd_delay=250
  171. [ -f /etc/conf/console ] && . /etc/conf/console
  172. [ "$con_term" ] || con_term=linux
  173. [ "$con_blank" ] || con_blank=0
  174. gui_menu general 'Various general system configurations' \
  175. "Set console keyboard mapping ....... $keymap" "set_keymap" \
  176. "Set console screen font ............ $vcfont" "set_vcfont" \
  177. "Set system-wide time zone .......... $tz" "set_tmarea" \
  178. "Set date and time (utc/localtime) .. $dtime" "set_dtime" \
  179. "Set system-wide locale (language) .. $locale" "set_locale" \
  180. "Set console keyboard repeat rate ... $kbd_rate" "set_kbd_rate" \
  181. "Set console keyboard repeat delay .. $kbd_delay" "set_kbd_delay" \
  182. "Set console screen terminal type ... $con_term" "set_con_term" \
  183. "Set console screen blank interval .. $con_blank" "set_con_blank" \
  184. "Run the (daily) 'cron.run' script now" "cron.run"
  185. do : ; done
  186. }