From 9a7c75dcb158b5df4cb8c016ef3169854d141145 Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Sat, 17 Feb 2024 12:34:41 +0100 Subject: [PATCH] fancontrol: Uplift the --check option - do not duplicate the load code - add description to man page --- prog/pwm/fancontrol | 14 +++++++------- prog/pwm/fancontrol.8 | 12 ++++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index bfceffb64..5b6e5b48e 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -390,15 +390,11 @@ function CheckFiles return $outdated } +CHECK_ONLY=false if [ "$1" == "--check" ] then - if [ -f "$2" ] - then - LoadConfig $2 - else - LoadConfig /etc/fancontrol - fi - exit 0 + CHECK_ONLY=true + shift fi if [ -f "$1" ] @@ -408,6 +404,10 @@ else LoadConfig /etc/fancontrol fi +if $CHECK_ONLY ; then + exit 0 +fi + # Detect path to sensors if echo "${AFCPWM[0]}" | grep -E -q '^/' then diff --git a/prog/pwm/fancontrol.8 b/prog/pwm/fancontrol.8 index 48190bc21..30bdefb46 100644 --- a/prog/pwm/fancontrol.8 +++ b/prog/pwm/fancontrol.8 @@ -3,14 +3,22 @@ fancontrol \- automated software based fan speed regulation .SH SYNOPSIS -.B fancontrol -.I [configfile] +.B fancontrol [ +.I --check +.B ] [ +.I configfile +.B ] .SH DESCRIPTION \fBfancontrol\fP is a shell script for use with lm_sensors. It reads its configuration from a file, then calculates fan speeds from temperatures and sets the corresponding PWM outputs to the computed values. +.SH OPTIONS +.IP "--check" +Check configuration file end exit. This option can be used for verifying the +configuration before starting fancontrol as a service in the background. + .SH WARNING Please be careful when using the fan control features of your mainboard, in addition to the risk of burning your CPU, at higher temperatures there will be