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.

180 lines
5.0 KiB

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