#!/bin/sh # # $FreeBSD: /tmp/pcvs/ports/sysutils/linux-megacli/files/Attic/mfi_tty_log.in,v 1.1 2008-10-13 17:22:20 stefan Exp $ # # PROVIDE: mfi_tty_log # REQUIRE: abi # KEYWORD: nojail : ${rc_mfi_raid_tty_log:=NO} . /etc/rc.subr name="mfi_tty_log" start_cmd="${name}_start" stop_cmd=":" mfi_tty_log_start() { megacli=${megacli:-%%PREFIX%%/sbin/megacli} logdir=${logdir:-/var/log} case "$rc_mfi_raid_tty_log" in [Yy][Ee][Ss]) echo echo 'Checking for TTY logs of MFI(4) RAID controllers:' ;; *) return 0 ;; esac if test `id -u` -ne 0; then echo "You must be root to run `basename $0`." >&2 return 1 fi ADPCOUNT=$(${megacli} -adpCount | \ awk '/Controller Count:/ { gsub("\\.", ""); print $3 }') case ${ADPCOUNT} in 0) echo "Error: Cannot find an adapter." >&2 return 1 ;; [1-9]|[1-9][0-9]|[1-2][0-9][0-9]) ;; *) echo "Error: Cannot get the number of adapters: ${ADPCOUNT}" >&2 return 1 ;; esac ADPMINIDX=0 ADPMAXIDX=`expr ${ADPCOUNT} - 1` for ctrl in `jot ${ADPCOUNT} ${ADPMINIDX} ${ADPMAXIDX}`; do tty_log=${logdir}/mfi_raid_${ctrl}_tty.boot echo " Adapter: ${ctrl} - TTY log saved to ${tty_log}" ${megacli} -FwTermLog Dsply -a${ctrl} > ${tty_log} done } run_rc_command "$1"