#!/bin/sh
#
# sets scaling govermor
#
# description: Set the CPU Frequency Scaling governor to the value from /etc/scaling_governor
#

. /opt/gira/share/devicestack/ipmodule-init.d-base

case "$1" in
    start)
	if [ -f /etc/scaling_governor ]
	then
	        SCALING_GOVERNOR=$(head -n1 /etc/scaling_governor)
        	msg "Set scaling governor for all cpus to ${SCALING_GOVERNOR}"
	        for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
        	do
                	[ -f $CPUFREQ ] || continue
	                msg "${SCALING_GOVERNOR} -> ${CPUFREQ}"
        	        echo -n ${SCALING_GOVERNOR} > $CPUFREQ
	        done
	else
		msg "No scaling governor set in /etc/scaling_governor - Skipping."
	fi
        ;;
    restart|reload|force-reload)
        msg "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        msg "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

