1#!/sbin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License, Version 1.0 only 7# (the "License"). You may not use this file except in compliance 8# with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or http://www.opensolaris.org/os/licensing. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23# 24# Copyright (c) 1998-2001 by Sun Microsystems, Inc. 25# All rights reserved. 26# 27#ident "%Z%%M% %I% %E% SMI" 28 29# Default location for script 30ncalogd=/etc/init.d/ncalogd 31success=1 32 33# Default config values used by script 34ncalogdconf=/etc/nca/ncalogd.conf 35ncakmodconf=/etc/nca/ncakmod.conf 36 37isValidFile() { 38 # Check if file exists 39 if [ ! -f $1 ] 40 then 41 # Create subdirectories 42 logd_dir=`/usr/bin/dirname $1` 43 if [ ! -d "$logd_dir" ]; then 44 /usr/bin/mkdir -m 0755 -p $logd_dir > /dev/null 2>&1 45 if [ $? != 0 ]; then 46 echo "Error: $ncalogd: unable to" \ 47 "create directory $logd_dir" 48 return 1 49 fi 50 fi 51 # Create the log file 52 touch $1 53 if [ $? != 0 ]; then 54 echo "Error: ${ncalogd}: unable to create file $1" 55 return 1 56 fi 57 fi 58 59 # test if valid local file 60 df -l $1 > /dev/null 2>&1 61 if [ $? != 0 ]; then 62 echo "Error: $ncalogd: $1 is not a local file system" 63 return 1 64 fi 65 return 0 66} 67 68isValidDev() { 69 # Check if device is valid 70 fsck -m $1 > /dev/null 2>&1 71 case $? in 72 36 | 39 ) 73 return 0 74 ;; 75 0 | 32 | 33 | 40 ) 76 echo "Error: $ncalogd: refusing to overwrite filesystem on $1" 77 return 1 78 ;; 79 * ) 80 echo "Error: $ncalogd: $1 is an invalid device" 81 return 1 82 ;; 83 esac 84} 85 86case "$1" in 87'start') 88 if [ ! -f $ncalogdconf ]; then 89 # If configuration file is missing, just exit 90 exit 0 91 fi 92 93 . $ncalogdconf 94 95 # Default is "disabled" so we want to exit 96 [ "x$status" != "xenabled" ] && exit 0 97 98 . $ncakmodconf 99 100 # Default is "disabled" so we want to exit 101 [ "x$status" != "xenabled" ] && exit 0 102 103 for i in $logd_path_name; do 104 # make sure that specified logfile is not a directory 105 if [ -d $i ]; then 106 echo "Error: $ncalogd: $i is a directory" 107 continue 108 elif [ -b $i -o -c $i ]; then 109 # Check if file is a device 110 isValidDev $i || continue 111 else 112 isValidFile $i || continue 113 fi 114 115 # Finally, set the specified file as a NCA log file 116 /usr/sbin/ndd -set /dev/nca nca_log_file $i 117 success=0 118 done 119 120 if [ $success = 0 ]; then 121 [ "x$logd_file_size" != "x" ] && \ 122 /usr/sbin/ndd -set /dev/nca nca_log_size $logd_file_size 123 /usr/sbin/ndd -set /dev/nca nca_logging_on 1 124 fi 125 ;; 126 127'stop') 128 . $ncakmodconf 129 130 if [ "x$status" = "xenabled" ]; then 131 /usr/sbin/ndd -set /dev/nca nca_logging_on 0 132 fi 133 ;; 134 135*) 136 echo "Usage: $0 { start | stop }" 137 exit 1 138 ;; 139esac 140exit 0 141