From 2b91e57d41b30e8bfd3c7b120da22913d11dde86 Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Thu, 29 Jan 2015 23:58:41 +0000 Subject: [PATCH] add separate init script and tweak ondemand params --- debian/raspi-config.init | 37 +++++++++++++++++++++++++++++++++++++ raspi-config | 38 -------------------------------------- 2 files changed, 37 insertions(+), 38 deletions(-) create mode 100644 debian/raspi-config.init diff --git a/debian/raspi-config.init b/debian/raspi-config.init new file mode 100644 index 0000000..c687b4b --- /dev/null +++ b/debian/raspi-config.init @@ -0,0 +1,37 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: raspi-config +# Required-Start: udev mountkernfs $remote_fs +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Switch to ondemand cpu governor (unless shift key is pressed) +# Description: +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + log_daemon_msg "Checking if shift key is held down" + timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT" + if [ $? -eq 0 ]; then + printf " Yes. Not enabling ondemand scaling governor" + log_end_msg 0 + else + printf " No. Switching to ondemand scaling governor" + SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + if [ -e $SYS_CPUFREQ_GOVERNOR ]; then + echo "ondemand" > $SYS_CPUFREQ_GOVERNOR + echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 100000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + fi + log_end_msg 0 + fi + ;; + *) + echo "Usage: $0 start" >&2 + exit 3 + ;; +esac diff --git a/raspi-config b/raspi-config index 38da53a..8bbce1b 100755 --- a/raspi-config +++ b/raspi-config @@ -317,44 +317,6 @@ set_overclock() { set_config_var core_freq $3 $CONFIG && set_config_var sdram_freq $4 $CONFIG && set_config_var over_voltage $5 $CONFIG && - # now set up an init.d script -cat <<\EOF > /etc/init.d/switch_cpu_governor && -#!/bin/sh -### BEGIN INIT INFO -# Provides: switch_cpu_governor -# Required-Start: udev mountkernfs $remote_fs -# Required-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Switch to ondemand cpu governor (unless shift key is pressed) -# Description: -### END INIT INFO - -. /lib/lsb/init-functions - -case "$1" in - start) - log_daemon_msg "Checking if shift key is held down" - timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT" - if [ $? -eq 0 ]; then - printf " Yes. Not switching scaling governor" - log_end_msg 0 - else - SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor - [ -e $SYS_CPUFREQ_GOVERNOR ] && echo "ondemand" > $SYS_CPUFREQ_GOVERNOR - echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold - printf " No. Switching to ondemand scaling governor" - log_end_msg 0 - fi - ;; - *) - echo "Usage: $0 start" >&2 - exit 3 - ;; -esac -EOF - chmod +x /etc/init.d/switch_cpu_governor && - update-rc.d switch_cpu_governor defaults && whiptail --msgbox "Set overclock to preset '$1'" 20 60 2 }