#!/bin/sh
#
#  Correct the current sense scale for secondary output2 in hwmon.local
#

CONFIGFILE="/etc/ioline/hwmon.local"

# Fast exit if the file does not exist.  Do this before the run once check
# so we run once when the file if first created.  Covers some unusual
# production/upgrade cases.
[ -e $CONFIGFILE ] || exit 0

# Only run once
[ -n "${POST_UPGRADE_CACHE}" ] && touch "${POST_UPGRADE_CACHE}/`basename $0`"

# Exactly three changes required in the file
if [ `grep -c '^scale = 0\.005$' $CONFIGFILE` = "3" ]
then
    echo " * Correcting current sense scales in $CONFIGFILE"
    sed -i -e '/^scale = 0\.005$/s//scale = 0.0025/' $CONFIGFILE
fi

exit 0
