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.

203 lines
5.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_hardware.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2005 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] 20 hardware Kernel Drivers and Hardware Configuration
  24. set_dev_setup() {
  25. echo "devtype=$1" > /etc/conf/devtype
  26. }
  27. set_hw_setup() {
  28. echo "HARDWARE_SETUP=$1" > /etc/conf/hardware
  29. }
  30. flip_hw_config() {
  31. local tmp=`mktemp`
  32. awk "\$0 == \"### $1 ###\", \$0 == \"\" {"'
  33. if ( /^#[^# ]/ ) {
  34. sub("^#", "");
  35. system($0 " >&2");
  36. } else {
  37. if ( /^[^# ]/ ) $0 = "#" $0;
  38. if (/^#modprobe /) {
  39. cmd = $0;
  40. sub("^#modprobe", "modprobe -r", cmd);
  41. system(cmd " >&2");
  42. }
  43. if (/^#mount /) {
  44. cmd = $0;
  45. sub("^#mount .* ", "umount ", cmd);
  46. system(cmd " >&2");
  47. }
  48. }
  49. } { print; }' < /etc/conf/kernel > $tmp
  50. cat $tmp > /etc/conf/kernel; rm -f $tmp
  51. # this is needed to e.g. initialize /proc/bus/usb/devices
  52. sleep 1
  53. }
  54. add_hw_config() {
  55. case $state in
  56. 1) cmd="$cmd '[ ] $name'" ;;
  57. 2) cmd="$cmd '[*] $name'" ;;
  58. *) cmd="$cmd '[?] $name'" ;;
  59. esac
  60. case $state in
  61. 1|2) cmd="$cmd 'flip_hw_config \"$id\"'" ;;
  62. *) cmd="$cmd 'true'" ;;
  63. esac
  64. id=""
  65. }
  66. store_clock() {
  67. if [ -f /etc/conf/clock ] ; then
  68. sed -e "s/clock_tz=.*/clock_tz=$clock_tz/" \
  69. -e "s/clock_rtc=.*/clock_rtc=$clock_rtc/" \
  70. < /etc/conf/clock > /etc/conf/clock.tmp
  71. grep -q clock_tz= /etc/conf/clock.tmp || \
  72. echo clock_tz=$clock_tz >> /etc/conf/clock.tmp
  73. grep -q clock_rtc= /etc/conf/clock.tmp || \
  74. echo clock_rtc=$clock_rtc >> /etc/conf/clock.tmp
  75. mv /etc/conf/clock.tmp /etc/conf/clock
  76. else
  77. echo -e "clock_tz=$clock_tz\nclock_rtc=$clock_rtc\n" \
  78. > /etc/conf/clock
  79. fi
  80. if [ -w /proc/sys/dev/rtc/max-user-freq -a "$clock_rtc" ] ; then
  81. echo $clock_rtc > /proc/sys/dev/rtc/max-user-freq
  82. fi
  83. }
  84. set_zone() {
  85. clock_tz=$1
  86. hwclock --hctosys --$clock_tz
  87. store_clock
  88. }
  89. set_rtc() {
  90. gui_input "Set new enhanced real time clock precision" \
  91. "$clock_rtc" "clock_rtc"
  92. store_clock
  93. }
  94. main() {
  95. while
  96. devtype=devfs
  97. if [ -f /etc/conf/devtype ]; then
  98. . /etc/conf/devtype
  99. fi
  100. HARDWARE_SETUP=hotplug
  101. if [ -f /etc/conf/hardware ]; then
  102. . /etc/conf/hardware
  103. fi
  104. clock_tz=utc
  105. clock_rtc="`cat /proc/sys/dev/rtc/max-user-freq 2> /dev/null`"
  106. if [ -f /etc/conf/clock ]; then
  107. . /etc/conf/clock
  108. fi
  109. cmd="gui_menu hw 'Kernel Drivers and Hardware Configuration'"
  110. for x in devfs udev static; do
  111. if [ "$devtype" = $x ]; then
  112. cmd="$cmd \"<*> Use $x /dev filesystem.\""
  113. else
  114. cmd="$cmd \"< > Use $x /dev filesystem.\""
  115. fi
  116. cmd="$cmd \"set_dev_setup $x\"";
  117. done
  118. cmd="$cmd '' ''";
  119. for x in hwscan hotplug rockplug; do
  120. [ -x /sbin/$x ] || continue
  121. if [ "$HARDWARE_SETUP" = $x ]; then
  122. cmd="$cmd \"<*> Use $x to configure hardware.\""
  123. else
  124. cmd="$cmd \"< > Use $x to configure hardware.\""
  125. fi
  126. cmd="$cmd \"set_hw_setup $x\"";
  127. done
  128. cmd="$cmd '' ''";
  129. if [ "$HARDWARE_SETUP" = rockplug ]; then
  130. cmd="$cmd 'Edit/View PCI configuration'";
  131. cmd="$cmd \"gui_edit PCI /etc/conf/pci\""
  132. cmd="$cmd 'Edit/View USB configuration'";
  133. cmd="$cmd \"gui_edit USB /etc/conf/usb\""
  134. cmd="$cmd '' ''";
  135. cmd="$cmd 'ROCK-Plug/Drivers Configuration'"
  136. cmd="$cmd 'stone rockplug' '' ''"
  137. cmd="$cmd 'Re-create initrd image (mkinitrd, `uname -r`)'"
  138. cmd="$cmd 'gui_cmd mkinitrd mkinitrd' '' ''"
  139. fi
  140. if [ "$HARDWARE_SETUP" = hwscan ]; then
  141. cmd="$cmd 'Edit /etc/conf/kernel (kernel drivers config file)'"
  142. cmd="$cmd \"gui_edit 'Kernel Drivers Config File' /etc/conf/kernel\""
  143. cmd="$cmd 'Re-create initrd image (mkinitrd, `uname -r`)'"
  144. cmd="$cmd 'gui_cmd mkinitrd mkinitrd' '' ''"
  145. hwscan -d -s /etc/conf/kernel
  146. id=""
  147. while read line; do
  148. if [ "${line#\#\#\# }" != "${line}" -a \
  149. "${line% \#\#\#}" != "${line}" ]
  150. then
  151. id="${line#\#\#\# }"; id="${id% \#\#\#}"
  152. state=0; name="Unamed Kernel Driver"
  153. elif [ -z "$id" ]; then
  154. continue
  155. elif [ "${line#\# }" != "${line}" ]; then
  156. name="${line#\# }"
  157. elif [ "${line#\#[!\# ]}" != "${line}" ]; then
  158. [ $state -eq 0 ] && state=1
  159. [ $state -eq 2 ] && state=3
  160. elif [ "${line#[!\# ]}" != "${line}" ]; then
  161. [ $state -eq 0 ] && state=2
  162. [ $state -eq 1 ] && state=3
  163. elif [ -z "$line" ]; then
  164. add_hw_config
  165. fi
  166. done < /etc/conf/kernel
  167. [ -z "$id" ] || add_hw_config
  168. cmd="$cmd '' ''"
  169. fi
  170. if [ "$clock_tz" = localtime ] ; then
  171. cmd="$cmd '[*] Use localtime instead of utc' 'set_zone utc'"
  172. else
  173. cmd="$cmd '[ ] Use localtime instead of utc' 'set_zone localtime'"
  174. clock_tz=utc
  175. fi
  176. cmd="$cmd 'Set enhanced real time clock precision ($clock_rtc)' set_rtc"
  177. eval "$cmd"
  178. do : ; done
  179. return
  180. }