Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- timestamp() {
- date +"%Y-%m-%d %T"
- }
- LOGDIR="/var/log/fan.log"
- VALUE=45
- TEMP=`/opt/vc/bin/vcgencmd measure_temp | cut -c6,7`
- STATUS=`cat /sys/class/gpio/gpio2/value`
- if [ -z "${STATUS}" ]; then
- echo "2">/sys/class/gpio/export
- echo "out">/sys/class/gpio/gpio2/direction
- fi
- #######echo `timestamp` " Info: Temperature: $TEMP">>$LOGDIR
- if [ $TEMP -ge $VALUE ] && [ $STATUS -eq 0 ]
- then
- #######echo `timestamp` " Warning: Fan started.">>$LOGDIR
- echo "1">/sys/class/gpio/gpio2/value
- elif [ $TEMP -le $VALUE ] && [ $STATUS -eq 1 ]
- then
- #######echo `timestamp` " Warning: Fan stopped.">>$LOGDIR
- echo "0">/sys/class/gpio/gpio2/value
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement