#!/bin/bash

set -euo pipefail

package=xdma
name=xdma

# __VERSION__ is replaced by the actual version in overrride_dh_auto_install in
# the rules
version="__VERSION__"

isadded=`dkms status -m "$name" -v "$version"`

if [ "x${isadded}" = "x" ] ; then
        dkms add -m "$name" -v "$version"
fi

if [ "$1" = 'configure' ] ; then
        bash /usr/lib/dkms/common.postinst "$name" "$version"
fi

echo "Unload old driver module......"
if lsmod | grep "$name"; then
        rmmod "$name"
fi

echo "Load new driver module......"
modprobe $name

#DEBHELPER#

exit 0
