#!/bin/sh
set -e
#set -x

. /usr/share/debconf/confmodule
#db_set prospect/suid
db_input medium prospect/suid || true
db_go || true

# check to see if oprofile is already installed, but also
# try several different methods of checking because there's
# no way we can a priori determine how the oprofile kernel
# module we need was put in place
oprofile=""
if [ -f /proc/modules ]
then
   oprofile=$(grep oprofile /proc/modules || true )

elif [ -f /lib/modules/`uname -r`/oprofile/oprofile.o ]
then
   oprofile="module installed"
else
   oprofile=$(dpkg -l '*oprofile*' 2>/dev/null | tail -1 | cut -d' ' -f1)
   if [ "$oprofile" != "ii" ]
   then
      oprofile=""
   fi
fi

if [ "${oprofile}X" != "X" ]
then
   db_set prospect/oprofile
   db_input medium prospect/oprofile || true
   db_go || true
fi

exit 0
