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.
78 lines
1.5 KiB
78 lines
1.5 KiB
#!/sbin/runscript
|
|
|
|
depend() {
|
|
need modules
|
|
before cpufrequtils
|
|
}
|
|
|
|
KERNEL_VERSION=`uname -r`
|
|
KERNEL_VERSION_CONF=${KERNEL_VERSION//./_}
|
|
KERNEL_VERSION_CONF="modules_${KERNEL_VERSION_CONF//-/_}"
|
|
MODULES_PATH="/lib/modules/${KERNEL_VERSION}"
|
|
CONF_FILE="/etc/conf.d/modules"
|
|
|
|
variable_value()
|
|
{
|
|
local varname=$1
|
|
cl-install -v --filter $varname |
|
|
awk "{ if (\$1 == \"$varname\") print \$3 }"
|
|
}
|
|
|
|
get_cpufreq_modules(){
|
|
MODULES_STRING=""
|
|
for path in $(find $MODULES_PATH -name cpufreq)
|
|
do
|
|
for module_path in $(find $path -name *.ko | sort)
|
|
do
|
|
module_name=${module_path##\/*\/}
|
|
module_name=${module_name%.ko}
|
|
if modprobe $module_name &>/dev/null;
|
|
then
|
|
if [[ ${MODULES_STRING} ]];
|
|
then
|
|
MODULES_STRING="${MODULES_STRING} $module_name"
|
|
else
|
|
MODULES_STRING=$module_name
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
}
|
|
|
|
find_string_modules(){
|
|
find_string=$(awk "/^\s*[^#]*\s*${KERNEL_VERSION_CONF}/ {print}" < ${CONF_FILE})
|
|
if [[ -n $find_string ]];
|
|
then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
add_autoload_modules(){
|
|
local roottype=`variable_value os_root_type`
|
|
if ! find_string_modules;
|
|
then
|
|
ebegin "Added rules for cpu frequency"
|
|
get_cpufreq_modules
|
|
if [[ $roottype == "hdd" ]]
|
|
then
|
|
echo ${KERNEL_VERSION_CONF}=\"${MODULES_STRING}\" >> ${CONF_FILE}
|
|
fi
|
|
else
|
|
ebegin "Cpu frequency modules already detected"
|
|
fi
|
|
}
|
|
|
|
start() {
|
|
add_autoload_modules
|
|
eend
|
|
}
|
|
|
|
stop() {
|
|
local roottype=`variable_value os_root_type`
|
|
if [[ $roottype == "hdd" ]] && rc-config list boot | grep -q calculate-builder
|
|
then
|
|
rc-update del calculate-builder boot
|
|
fi
|
|
}
|