commit b78154d17638645d9828c3e91ca5641b505fcf02 Author: Alec Lombardo Date: Sat Jan 11 10:42:36 2020 -0500 Initial commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2876553 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +publish.sh +README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d98f36a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:latest + +RUN apt-get update + +RUN apt-get install ipmitool cron -y + +COPY crontab /etc/cron.d/fan-control + +RUN chmod 0777 /etc/cron.d/fan-control + +RUN touch /var/log/cron.log + +ADD check-temp.sh /opt/check-temp.sh + +ADD startup.sh /startup.sh + +RUN chmod 0777 /opt/check-temp.sh + +RUN chmod 0777 /startup.sh + +RUN /usr/bin/crontab /etc/cron.d/fan-control + +# you should override these when running. See README.md +ENV IDRAC_HOST 192.168.1.100 +ENV IDRAC_USER root +ENV IDRAC_PW calvin +ENV FANSPEED 0x05 +CMD /startup.sh && cron && tail -f /var/log/cron.log \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d835973 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# IDRAC Fan Controller Docker Image + +To use, + +`docker run -e IDRAC_HOST= -e IDRAC_USER= -e IDRAC_PW= -e FANSPEED= alombardo4/idrac-fan-control:latest` + +`FANSPEED` should be set as a hex value, e.g. `0x05` + +Example `docker-compose.yml`: + +```yml +version: '3' + +services: + fan-controller: + image: alombardo4/idrac-fan-control + environment: + - IDRAC_HOST=192.168.1.100 # override to the IP of your IDRAC + - IDRAC_USER=root # set to your IPMI username + - IDRAC_PW=calvin # set to your IPMI password + - FANSPEED=0x05 # set to the hex value you want to set the fans to (from 0 to 100) +``` diff --git a/check-temp.sh b/check-temp.sh new file mode 100755 index 0000000..bdbb7d2 --- /dev/null +++ b/check-temp.sh @@ -0,0 +1,19 @@ +IPMIHOST=`cat /host.txt` +IPMIUSER=`cat /user.txt` +IPMIPW=`cat /pw.txt` +FANSPEED=`cat /fanspeed.txt` + +MAXTEMP=32 + +TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1) + +echo "Current Temp is $TEMP C" +if [ $TEMP -gt $MAXTEMP ]; +then + echo "Temp is too high. Activating dynamic fan control" + ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x01 +else + echo "Temp is OK. Using manual fan control" + ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x01 0x00 + ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff $FANSPEED +fi diff --git a/crontab b/crontab new file mode 100644 index 0000000..f1e3416 --- /dev/null +++ b/crontab @@ -0,0 +1 @@ +* * * * * /bin/bash -c "/opt/check-temp.sh &> /var/log/cron.log" diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..5c0bf01 --- /dev/null +++ b/publish.sh @@ -0,0 +1,2 @@ +docker build . -t alombardo4/idrac-fan-control:latest && \ +docker push alombardo4/idrac-fan-control \ No newline at end of file diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..5f6b85a --- /dev/null +++ b/startup.sh @@ -0,0 +1,9 @@ +echo $IDRAC_HOST >> /host.txt +echo $IDRAC_USER >> /user.txt +echo $IDRAC_PW >> /pw.txt +echo $FANSPEED >> /fanspeed.txt + +echo "Host: `cat /host.txt`" +echo "User: `cat /user.txt`" +echo "PW: `cat /pw.txt`" +echo "Fan speed `cat /fanspeed.txt`" diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..8d50f1d --- /dev/null +++ b/update.sh @@ -0,0 +1 @@ +docker build -t alombardo4/idrac6-fan-control:1.0.2 . && docker push alombardo4/idrac6-fan-control:1.0.2 \ No newline at end of file