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.
calculate-utils-2.2-builder/data/calculate-builder

65 lines
1.2 KiB

#!/sbin/runscript
depend() {
need modules
}
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"
get_cpufreq_modules(){
MODULES_STRING=""
for path in $(find $MODULES_PATH -name cpufreq)
do
for module_path in $(find $path -name *.ko)
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(){
if ! find_string_modules;
then
ebegin "Added rules for cpu frequency"
get_cpufreq_modules
echo ${KERNEL_VERSION_CONF}=\"${MODULES_STRING}\" >> ${CONF_FILE}
else
ebegin "Cpu frequency modules already detected"
fi
}
start() {
add_autoload_modules
eend
}
stop() {
if rc-update show boot | grep -q calculate-builder
then
rc-update del calculate-builder boot
fi
}