From 229d03f7f2eb4c625d29ec6e59345b0995209bc1 Mon Sep 17 00:00:00 2001 From: Frederik <5511687+fightforlife@users.noreply.github.com> Date: Sun, 8 May 2022 11:46:51 +0200 Subject: [PATCH] optional params and temp query mode (#4) * first test * autobuild dev * fix * tests * further test * arg array * optional args and workflow * test * test2 * test3 * reverse uno * Update README.md --- .github/workflows/docker-publish.yml | 2 ++ README.md | 10 +++++---- start_services.sh | 32 +++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 49a1116..b93beed 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -8,11 +8,13 @@ name: Publish Docker image on: push: branches: + - 'dev' - 'master' tags: - 'v*' pull_request: branches: + - 'dev' - 'master' # schedule: diff --git a/README.md b/README.md index e4c8784..1a27d5f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ simple Docker image for hddfancontrol by desbma https://github.com/desbma/hddfancontrol This is a docker image which includes the following programs to run **hddfancontrol** by desbma. -- smartmontools - needed for the new --smartctl option, which uses smartmontolls instead of hdparm to spindown drives +- smartmontools - needed for the --smartctl option, which uses smartmontolls instead of hdparm to spindown drives - hdparm - old way of spinning down drives - hddtemp - to get hddtemps - fancontrol - to control PWM fan speed @@ -11,6 +11,7 @@ This is a docker image which includes the following programs to run **hddfancont ### Docker compose - currently privbiliged mode is used, since I didnt find an easy way to bind the sysfs hwmon instances +- all ENV variables are optional, but hddfancontrol will complain when something important is missing. ``` version: "3" services: @@ -31,8 +32,9 @@ services: - MAX_TEMP=60 - MIN_FAN=0 - INTERVALL=60 - - SPINDOWN_TIME=900 - - LOG_PATH=/var/log/hddfancontrol.log + - SPINDOWN_TIME=900 (optional!) + - TEMP_QUERY_MODE=smartctl + - LOG_PATH=/var/log/hddfancontrol.log (optional!) ``` @@ -41,5 +43,5 @@ services: - [ ] Find a way to get rid of the priviliged mode and use the devices directly - [X] incoperate lm-sensors into the container including the kernel modules - [ ] run and expose hddtemp daemon -- [ ] make way of fetching temp a config +- [X] make way of fetching temp a config diff --git a/start_services.sh b/start_services.sh index 8e30192..b14d1fd 100644 --- a/start_services.sh +++ b/start_services.sh @@ -3,19 +3,25 @@ #detect sensors and load modules sensors-detect --auto | sed -n '/# Chip drivers/,/#----cut here----/{//!p;}' | xargs -n1 modprobe -hddfancontrol -d $DEVICES \ - -p $PWM_DEVICES \ - --pwm-start-value $PWM_START \ - --pwm-stop-value $PWM_STOP \ - --min-temp $MIN_TEMP \ - --max-temp $MAX_TEMP \ - --min-fan-speed-prct $MIN_FAN \ - -i $INTERVALL \ - --spin-down-time $SPINDOWN_TIME \ - --smartctl \ - -l $LOG_PATH \ - & - +#create argument array +declare -a args=() + +[[ ! -z $DEVICES ]] && args+=(--drives $DEVICES) +[[ ! -z $PWM_DEVICES ]] && args+=(--pwm $PWM_DEVICES) +[[ ! -z $PWM_START ]] && args+=(--pwm-start-value $PWM_START) +[[ ! -z $PWM_STOP ]] && args+=(--pwm-stop-value $PWM_STOP) +[[ ! -z $MIN_TEMP ]] && args+=(--min-temp $MIN_TEMP) +[[ ! -z $MAX_TEMP ]] && args+=(--max-temp $MAX_TEMP) +[[ ! -z $MIN_FAN ]] && args+=(--min-fan-speed-prct $MIN_FAN) +[[ ! -z $INTERVALL ]] && args+=(-i $INTERVALL) +[[ ! -z $TEMP_QUERY_MODE ]] && args+=(--$TEMP_QUERY_MODE) +[[ ! -z $SPINDOWN_TIME ]] && args+=(--spin-down-time $SPINDOWN_TIME) +[[ ! -z $LOG_PATH ]] && args+=(-l $LOG_PATH) + +echo ${args[@]} + +hddfancontrol ${args[@]} & + # Wait for any process to exit wait -n