freebsd-ports/sysutils/linux-megacli/files/megacli.sh.in
Stefan Walter 13a94294db - Add rc.d script for taking TTY logs. [1]
- Don't complain about higher compat.linux.osrelease versions. [2]

PR:		126040
Submitted by:	bz [1], maintainer [2]
Approved by:	maintainer [1]
2008-10-13 17:22:20 +00:00

66 lines
1.2 KiB
Bash

#!/bin/sh
# check for root user
#
if [ `id -u` -ne 0 ]
then
echo "You must be root to run `basename $0`." >&2
exit 1
fi
osrelease=`sysctl -n compat.linux.osrelease`
case $osrelease in
2.6.*)
if [ `echo $osrelease | cut -d . -f 3` -lt 12 ]; then
osrelease=TOOLOW
fi
;;
2.*)
if [ `echo $osrelease | cut -d . -f 2` -lt 6 ]; then
osrelease=TOOLOW
fi
;;
*)
if [ `echo $osrelease | cut -d . -f 1` -lt 2 ]; then
osrelease=TOOLOW
fi
;;
esac
if [ $osrelease = "TOOLOW" ]; then
echo "You need to set compat.linux.osrelease to atleast 2.6.12 to run `basename $0`." >&2
exit 1
fi
lpfs=`mount -t linprocfs | awk 'END{ print NR }'`
if [ ${lpfs} -le 0 ]; then
echo "You need to mount linprocfs to run `basename $0`." >&2
exit 1
fi
lsfs=`mount -t linsysfs | awk 'END{ print NR }'`
if [ ${lsfs} -le 0 ]; then
echo "You need to mount linsysfs to run `basename $0`." >&2
exit 1
fi
# check for active mfi_linux.ko
#
if ! kldstat -q -m mfi_linux
then
if kldload mfi_linux
then
echo 'mfi_linux module loaded.' >&2
else
echo 'mfi_linux module failed to load.' >&2
exit 1
fi
fi
if [ $# -le 0 ]; then
echo "usage: `basename $0` [options]" >&2
exec %%PREFIX%%/libexec/MegaCli -h
fi
exec %%PREFIX%%/libexec/MegaCli ${*}