From f6a794363ff9b640bae3349de6e36610ca0a20c7 Mon Sep 17 00:00:00 2001 From: celso Date: Sat, 19 Nov 2022 13:22:12 -0300 Subject: [PATCH] fixed README again and added openrc service --- Makefile | 4 ++++ README.md | 12 ++++++------ conf.d/homemade_speedstep | 7 +++++++ init.d/homemade_speedstep | 26 ++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 conf.d/homemade_speedstep create mode 100755 init.d/homemade_speedstep diff --git a/Makefile b/Makefile index c5ed154..606f09e 100644 --- a/Makefile +++ b/Makefile @@ -15,5 +15,9 @@ debug: install: cp $(BINDIR)/$(BIN) /usr/bin/$(BIN) +install-openrc: + cp init.d/$(BIN) /etc/init.d/$(BIN) + cp conf.d/$(BIN) /etc/conf.d/$(BIN) + clean: $(RM) -r $(BINDIR)/* diff --git a/README.md b/README.md index cbf2892..23a4ea7 100644 --- a/README.md +++ b/README.md @@ -41,18 +41,18 @@ You must provide the temperature at which you wish to step down the maximum freq Using OpenRC this would be done by adding the following in a `/etc/init.d/homemade_speedstep` file: ``` -#/sbin/openrc-run +#!/sbin/openrc-run name="homemade_speedstep" description="crude imitation of intel's speedstep" -command="/usr/bin/homemade_speedstep" +command=/usr/bin/homemade_speedstep command_args="${HSMAXTEMP} ${HSMINTEMP}" command_background=true +pidfile="/run/${RC_SVCNAME}.pid" checkconfig() { - if [ ${HSMAXTEMP} -lt 100000 ] && [ ${HSMINTEMP} -lt ${HSMAXTEMP} ] - then return 0 + if [ ${HSMAXTEMP} -lt 100000 ] && [ ${HSMINTEMP} -lt ${HSMAXTEMP} ] ; then + return 0 fi - return 1 } start_pre() { @@ -77,4 +77,4 @@ HSMAXTEMP=82000 # Lower temperature threshold HSMINTEMP=70000 ``` -and finally running `rc-update add homemade_speedstep default` \ No newline at end of file +and finally running `rc-update add homemade_speedstep default` diff --git a/conf.d/homemade_speedstep b/conf.d/homemade_speedstep new file mode 100644 index 0000000..f11c394 --- /dev/null +++ b/conf.d/homemade_speedstep @@ -0,0 +1,7 @@ +# /etc/conf.d/homemade_speedstep: config gile for /etc/init.d/homemade_speedstep + +# Change these to your liking +# Upper temperature threshold +HSMAXTEMP=82000 +# Lower temperature threshold +HSMINTEMP=70000 diff --git a/init.d/homemade_speedstep b/init.d/homemade_speedstep new file mode 100755 index 0000000..4cfdd61 --- /dev/null +++ b/init.d/homemade_speedstep @@ -0,0 +1,26 @@ +#!/sbin/openrc-run +name="homemade_speedstep" +description="crude imitation of intel's speedstep" +command=/usr/bin/homemade_speedstep +command_args="${HSMAXTEMP} ${HSMINTEMP}" +command_background=true +pidfile="/run/${RC_SVCNAME}.pid" + +checkconfig() { + if [ ${HSMAXTEMP} -lt 100000 ] && [ ${HSMINTEMP} -lt ${HSMAXTEMP} ] ; then + return 0 + fi +} + +start_pre() { + # Prevent of double check + if [ "${RC_CMD}" != "restart" ] ; then + checkconfig || return $? + fi +} + +stop_pre() { + if [ "${RC_CMD}" = "restart" ] ; then + checkconfig || return $? + fi +}