#!/bin/bash CMD=("ssh" "-oHostKeyAlgorithms=+ssh-rsa" "-oControlPath=/tmp/ilo.sock" "-oKexAlgorithms=diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" "-oPubkeyAcceptedKeyTypes=+ssh-rsa" "-i/root/.ssh/id_ilo" "Administrator@192.168.11.7") if [ ! -e /tmp/ilo.sock ]; then "${CMD[@]}" "-oControlMaster=yes" "-f" fi HIGHEST_TEMP=$(ipmi-sensors | cut -d'|' -f4 | sort -nr | head -n1 | sed "s/ *//" | cut -d'.' -f1) RUN=0 if [ "${HIGHEST_TEMP}" -ge 75 ]; then # panic mode SPEED0=255 SPEED1=255 elif [ "${HIGHEST_TEMP}" -ge 70 ]; then # hot SPEED0=185 SPEED1=150 elif [ "${HIGHEST_TEMP}" -ge 65 ]; then # warm SPEED0=125 SPEED1=100 else # cool SPEED0=100 SPEED1=75 fi if [ -f "/tmp/lasttemp" ]; then if [ "$(cat /tmp/lastspeed)" -ne "${SPEED1}" ]; then RUN=1 fi else RUN=1 fi echo "${SPEED1}" > /tmp/lastspeed if [ "${RUN}" -eq "1" ]; then # main fan (iLO/HD Controller/LAN/etc) ${CMD[@]} "-oControlMaster=no" -t fan p 0 max ${SPEED0}; ${CMD[@]} "-oControlMaster=no" -t fan p 1 max ${SPEED0}; # rest of the fans for f in `seq 2 7`; do ${CMD[@]} "-oControlMaster=no" -t fan p ${f} max ${SPEED1}; done fi