]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/initscripts/init.d/cpufreq
nut: Added status option, some installation fixed
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / cpufreq
index e15037caf0d047a05bb6ea35f3183ed6a5601a7b..5f28be2cf42e98bfb0d43251dcf95e6ebc4eccec 100644 (file)
@@ -6,7 +6,7 @@
 #
 # Authors     : Arne Fitzenreiter - arne_f@ipfire.org
 #
-# Version     : 00.00
+# Version     : 01.00
 #
 # Notes       :
 #
 
 case "${1}" in
        start)
-               boot_mesg "Starting cpufreq ..."
-               # Chose your cpufreq module, acpi-cpufreq should work with
-               # newer hardware
-               modprobe acpi-cpufreq
-               # modprobe cpufreq-nforce2
-               # modprobe e-powersaver
-               # modprobe gx-suspmod
-               # modprobe longhaul
-               # modprobe longrun
-               # modprobe p4-clockmod
-               # modprobe powernow-k6
-               # modprobe powernow-k7
-               # modprobe powernow-k8
-               # modprobe speedstep-centrino
-               # modprobe speedstep-ich
-               # modprobe speedstep-lib
-               # modprobe speedstep-smi
-               
+               boot_mesg -n "Starting cpufreq... "
+
+               # try cpufreq hardware depend modules
+               for i in $(find /lib/modules/$(uname -r)/kernel/arch/x86/kernel/cpu/cpufreq \
+                          ! -name speedstep-lib.ko | sort -d -r); do
+                       module=$(basename $i | cut -d. -f1);
+                       modprobe $module > /dev/null 2>&1;
+                       if [ ${?} = 0 ]; then
+                           boot_mesg -n "$SUCCESS$module$NORMAL "
+                       fi
+               done
+               boot_mesg ""
+
                # load cqufreq governors
                modprobe cpufreq_conservative
                modprobe cpufreq_ondemand
                modprobe cpufreq_powersave
                modprobe cpufreq_userspace
 
-               # Set the governor to ondemand 
+               CPUCOUNT=`ls /sys/devices/system/cpu/cpu*/cpufreq/affected_cpus 2> /dev/null | wc -l `;
+               let CPUCOUNT-=1
+               # Set the governor to ondemand to test if it works 
                cpufreq-set -g ondemand
-               evaluate_retval;
-               
-               # activate cpufreq collectd module
-               sed -i -e "s|#LoadPlugin cpufreq|LoadPlugin cpufreq|g" /etc/collectd.conf
+               if [ ${?} = 0 ]; then
+                   # activate cpufreq collectd module
+                   sed -i -e "s|^#LoadPlugin cpufreq|LoadPlugin cpufreq|g" /etc/collectd.conf
 
+                   # Set the governor to ondemand for all cpus 
+                   for i in `seq 0 $CPUCOUNT`;
+                   do
+                       cpufreq-set -c $i -g ondemand
+                   done
+                   echo_ok;
+               else
+                   echo_failure;
+               fi
                exit 0;
                ;;
        *)
@@ -57,3 +62,5 @@ case "${1}" in
 esac
 
 # End $rc_base/init.d/cpufreq
+
+