post_install (){ DKMS=$(which dkms) $DKMS add -m frandom -v 1.1 $DKMS build -m frandom -v 1.1 $DKMS install -m frandom -v 1.1 /usr/bin/depmod -a } pre_upgrade(){ pre_remove } post_upgrade(){ post_install } pre_remove (){ _inmemory=$(/usr/bin/lsmod | /usr/bin/grep frandom) if [ ! -z "$_inmemory" ]; then /usr/bin/rmmod frandom &> /dev/null fi DKMS=$(which dkms) _line=$($DKMS status -m frandom) if echo "$_line" | grep -E 'added|built|installed'; then version=$(echo "$_line" | sed 's/frandom,\([^,]*\)[,:].*/\1/;t;d') $DKMS remove -m frandom -v $version --all fi } post_remove () { /usr/bin/depmod -a } op=$1 shift $op $*