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.

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