components/rsyslog/files/rsyslog
changeset 847 4ae04177ffa1
child 4431 d851c2eccfcc
equal deleted inserted replaced
846:fe258446a1ae 847:4ae04177ffa1
       
     1 #!/usr/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 (the "License").
       
     7 # You may not use this file except in compliance with the License.
       
     8 #
       
     9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
    10 # or http://www.opensolaris.org/os/licensing.
       
    11 # See the License for the specific language governing permissions
       
    12 # and limitations under the License.
       
    13 #
       
    14 # When distributing Covered Code, include this CDDL HEADER in each
       
    15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    16 # If applicable, add the following below this CDDL HEADER, with the
       
    17 # fields enclosed by brackets "[]" replaced with your own identifying
       
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
       
    19 #
       
    20 # CDDL HEADER END
       
    21 #
       
    22 # Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
       
    23 #
       
    24 
       
    25 . /lib/svc/share/smf_include.sh
       
    26 
       
    27 SVC_FMRI=svc:/system/system-log
       
    28 DEFAULT_FMRI=${SVC_FMRI}:default
       
    29 OLD_METHOD1="kill -HUP \`cat /var/run/syslog.pid\`"
       
    30 OLD_METHOD2="kill -HUP \`cat /system/volatile/syslog.pid\`"
       
    31 NEW_METHOD="/usr/sbin/svccfg -s $SVC_FMRI refresh"
       
    32 LOGADM_CONF=/etc/logadm.conf
       
    33 
       
    34 if [ ! -f /etc/rsyslog.conf ]; then
       
    35 	echo "/etc/rsyslog.conf not found. Exiting."
       
    36 	exit $SMF_EXIT_ERR_CONFIG
       
    37 fi
       
    38 
       
    39 if [ ! -f /usr/lib/rsyslog/rsyslogd ]; then
       
    40 	echo "/usr/lib/rsyslog/rsyslogd not found. Exiting."
       
    41 	exit $SMF_EXIT_ERR_CONFIG
       
    42 fi
       
    43 
       
    44 if [ ! -x /usr/lib/rsyslog/rsyslogd ]; then
       
    45 	echo "/usr/lib/rsyslog/rsyslogd not executable. Exiting."
       
    46 	exit $SMF_EXIT_ERR_CONFIG
       
    47 fi
       
    48 
       
    49 default=$(/usr/bin/svcprop -c -p general/enabled $DEFAULT_FMRI)
       
    50 if [ $default = true ]; then
       
    51 	echo "$DEFAULT_FMRI conflicts with this instance and must be disabled first. Exiting."
       
    52 	exit $SMF_EXIT_ERR_CONFIG
       
    53 fi
       
    54 
       
    55 if smf_is_globalzone; then
       
    56 	#
       
    57 	# Before [r]syslogd starts, save any messages from
       
    58 	# previous crash dumps so that messages appear
       
    59 	# in chronological order.
       
    60 	#
       
    61 	/usr/bin/savecore -m
       
    62 	if [ -r /etc/dumpadm.conf ]; then
       
    63 		. /etc/dumpadm.conf
       
    64 		[ -n "$DUMPADM_DEVICE" -a \
       
    65 		"$DUMPADM_DEVICE" != swap ] && \
       
    66 		/usr/bin/savecore -m -f $DUMPADM_DEVICE
       
    67 	fi
       
    68 fi
       
    69 if [ ! -f /var/adm/messages ]; then
       
    70 	/usr/bin/cp /dev/null /var/adm/messages
       
    71 	/usr/bin/chmod 0644 /var/adm/messages
       
    72 fi
       
    73 
       
    74 # Convert the old PID-file based post-command for logadm to an SMF-based one.
       
    75 TMP_CONF=$(/usr/bin/mktemp /tmp/logadm.conf.XXXXXX)
       
    76 /usr/bin/sed -e "s|$OLD_METHOD1|$NEW_METHOD|" \
       
    77     -e "s|$OLD_METHOD2|$NEW_METHOD|" $LOGADM_CONF > $TMP_CONF
       
    78 /usr/bin/cmp -s $LOGADM_CONF $TMP_CONF
       
    79 if [ $? -eq 0 ]; then
       
    80 	/usr/bin/rm $TMP_CONF
       
    81 else
       
    82 	# In case the umask or group is odd.
       
    83 	mode=$(/usr/bin/stat -c %a $LOGADM_CONF)
       
    84 	owner_group=$(/usr/bin/stat -c %U:%G $LOGADM_CONF)
       
    85 	/usr/bin/mv $TMP_CONF $LOGADM_CONF
       
    86 	/usr/bin/chmod $mode $LOGADM_CONF
       
    87 	/usr/bin/chown $owner_group $LOGADM_CONF
       
    88 fi
       
    89 
       
    90 # The -c4 argument is needed to silence a compatibility warning.
       
    91 /usr/lib/rsyslog/rsyslogd -c4 >/dev/msglog 2>&1 &