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.

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