#!/bin/sh

# Copyright (c) 2022, Juniper Networks, Inc.
# All rights reserved

# called by package.sh to get the module loaded
# obviously if we are called the package is installed and active
# we may just need to mount it

check_module() {
    x=`sysctl -qn jnpr.compat.osreldate`
    case "$x" in
    [1-9][0-9]*????[0-9]) exit 0;;
    esac
}

check_module

# we have work to do
FWDCOMPAT_OK=/modules/fwdcompat.ko

Mydir=`dirname $0`
pkgdir=`cd $Mydir/.. && 'pwd'`

if [ -s $FWDCOMPAT_OK ]; then
    kldload $FWDCOMPAT_OK
else
    pkg mount $pkgdir
fi
check_module
exit 1
