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.

161 lines
4.6 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 - 2006 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. get_module_dependencies() {
  25. module="${1}"
  26. deps=`/sbin/modinfo -F depends ${module} 2>/dev/null | tr ',' ' '`
  27. if [ -n "${deps}" ] ; then
  28. for dep in ${deps} ; do
  29. echo "`get_module_dependencies ${dep}`"
  30. done
  31. fi
  32. echo "${module}";
  33. }
  34. get_initrd_module_cmds() {
  35. ret=""
  36. modules=`grep '^modprobe ' /etc/conf/kernel | grep -v 'no-initrd' | \
  37. sed 's,[ ]#.*,,' | \
  38. while read a b c; do
  39. echo "${b}"
  40. done`
  41. for module in ${modules} ; do
  42. module_dependencies=`get_module_dependencies ${module} | sort | uniq`
  43. if [ -n "${module_dependencies}" -a "${module_dependencies}" != "${module}" ] ; then
  44. ret="$ret '${module} (adds: ${module_dependencies})' 'remove_module_from_initrd \"${module}\"'"
  45. else
  46. ret="$ret '${module}' 'remove_module_from_initrd \"${module}\"'"
  47. fi
  48. done
  49. echo ${ret}
  50. }
  51. add_module_to_initrd() {
  52. gui_input "Module to add to initrd: " "" "addmodule"
  53. [ -z "${addmodule}" ] && return;
  54. kernel=`uname -r`
  55. module="`find /lib/modules/${kernel} -name "${addmodule}.o" -o -name "${addmodule}.ko" 2>/dev/null`"
  56. if [ -z "${module}" ] ; then
  57. gui_message "Error: No such module in /lib/modules/$kernel!";
  58. else
  59. echo "modprobe ${addmodule}" >> /etc/conf/kernel
  60. fi
  61. recreate_initrd=1
  62. }
  63. remove_module_from_initrd() {
  64. module=${1};
  65. grep -v '^modprobe[ ].*'${module} /etc/conf/kernel > /etc/conf/kernel.new
  66. mv /etc/conf/kernel.new /etc/conf/kernel
  67. recreate_initrd=1
  68. }
  69. set_dev_setup() {
  70. echo "devtype=$1" > /etc/conf/devtype
  71. }
  72. store_clock() {
  73. if [ -f /etc/conf/clock ] ; then
  74. sed -e "s/clock_tz=.*/clock_tz=$clock_tz/" \
  75. -e "s/clock_rtc=.*/clock_rtc=$clock_rtc/" \
  76. < /etc/conf/clock > /etc/conf/clock.tmp
  77. grep -q clock_tz= /etc/conf/clock.tmp || \
  78. echo clock_tz=$clock_tz >> /etc/conf/clock.tmp
  79. grep -q clock_rtc= /etc/conf/clock.tmp || \
  80. echo clock_rtc=$clock_rtc >> /etc/conf/clock.tmp
  81. mv /etc/conf/clock.tmp /etc/conf/clock
  82. else
  83. echo -e "clock_tz=$clock_tz\nclock_rtc=$clock_rtc\n" \
  84. > /etc/conf/clock
  85. fi
  86. if [ -w /proc/sys/dev/rtc/max-user-freq -a "$clock_rtc" ] ; then
  87. echo $clock_rtc > /proc/sys/dev/rtc/max-user-freq
  88. fi
  89. }
  90. set_zone() {
  91. clock_tz=$1
  92. hwclock --hctosys --$clock_tz
  93. store_clock
  94. }
  95. set_rtc() {
  96. gui_input "Set new enhanced real time clock precision" \
  97. "$clock_rtc" "clock_rtc"
  98. store_clock
  99. }
  100. main() {
  101. while
  102. devtype=udev
  103. if [ -f /etc/conf/devtype ]; then
  104. . /etc/conf/devtype
  105. fi
  106. clock_tz=utc
  107. clock_rtc="`cat /proc/sys/dev/rtc/max-user-freq 2> /dev/null`"
  108. if [ -f /etc/conf/clock ]; then
  109. . /etc/conf/clock
  110. fi
  111. cmd="gui_menu hw 'Kernel Drivers and Hardware Configuration'"
  112. for x in devfs udev static; do
  113. if [ "$devtype" = $x ]; then
  114. cmd="$cmd \"<*> Use $x /dev filesystem.\""
  115. else
  116. cmd="$cmd \"< > Use $x /dev filesystem.\""
  117. fi
  118. cmd="$cmd \"set_dev_setup $x\"";
  119. done
  120. cmd="$cmd '' ''";
  121. # initrd module handling
  122. cmd="$cmd 'Add module to initrd' 'add_module_to_initrd'";
  123. cmd="$cmd '' ''";
  124. cmd="$cmd 'Current initrd modules, select to remove: ' ''";
  125. cmd="$cmd `get_initrd_module_cmds`";
  126. cmd="$cmd '' ''";
  127. cmd="$cmd 'Force initrd re-creation now' '/sbin/mkinitrd; recreate_initrd=0'";
  128. cmd="$cmd '' ''";
  129. if [ "$clock_tz" = localtime ] ; then
  130. cmd="$cmd '[*] Use localtime instead of utc' 'set_zone utc'"
  131. else
  132. cmd="$cmd '[ ] Use localtime instead of utc' 'set_zone localtime'"
  133. clock_tz=utc
  134. fi
  135. cmd="$cmd 'Set enhanced real time clock precision ($clock_rtc)' set_rtc"
  136. eval "$cmd"
  137. do : ; done
  138. return
  139. }