#!/bin/sh
#    Debian post-install script
#
sbindir=/usr/sbin
vardir=/var/lib/ipmiutil
sensorout=$vardir/sensor_out.txt

mkdir -p $vardir

# Run some ipmiutil command to see if any IPMI interface works.
$sbindir/ipmiutil sel -v >/dev/null 2>&1
IPMIret=$?

# If IPMIret==0, the IPMI cmd was successful, and IPMI is enabled locally.
if [ $IPMIret -eq 0 ]; then
   if [ -d /etc/cron.daily ]; then
      cp -f /usr/share/ipmiutil/checksel /etc/cron.daily
   fi
   # Capture a snapshot of IPMI sensor data once now for later reuse.
   if [ ! -f $sensorout ]; then
      $sbindir/ipmiutil sensor -q >$sensorout
   fi
fi

