components/rsyslog/files/rsyslog
author Petr Sumbera <petr.sumbera@oracle.com>
Mon, 20 Jul 2015 01:38:31 -0700
branchs11-update
changeset 4676 60d2b233e6cc
parent 4450 423f06e4bc35
permissions -rw-r--r--
20912751 problem in LIBRARY/LIBXML

#!/usr/sbin/sh
#

#
# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
#

. /lib/svc/share/smf_include.sh

SVC_FMRI=svc:/system/system-log
DEFAULT_FMRI=${SVC_FMRI}:default
OLD_METHOD1="kill -HUP \`cat /var/run/syslog.pid\`"
OLD_METHOD2="kill -HUP \`cat /system/volatile/syslog.pid\`"
NEW_METHOD="/usr/sbin/svccfg -s $SVC_FMRI refresh"
LOGADM_CONF=/etc/logadm.conf

if [ ! -f /etc/rsyslog.conf ]; then
	echo "/etc/rsyslog.conf not found. Exiting."
	exit $SMF_EXIT_ERR_CONFIG
fi

if [ ! -f /usr/lib/rsyslog/rsyslogd ]; then
	echo "/usr/lib/rsyslog/rsyslogd not found. Exiting."
	exit $SMF_EXIT_ERR_CONFIG
fi

if [ ! -x /usr/lib/rsyslog/rsyslogd ]; then
	echo "/usr/lib/rsyslog/rsyslogd not executable. Exiting."
	exit $SMF_EXIT_ERR_CONFIG
fi

default=$(/usr/bin/svcprop -c -p general/enabled $DEFAULT_FMRI)
if [ $default = true ]; then
	echo "$DEFAULT_FMRI conflicts with this instance and must be disabled first. Exiting."
	exit $SMF_EXIT_ERR_CONFIG
fi

if smf_is_globalzone; then
	#
	# Before [r]syslogd starts, save any messages from
	# previous crash dumps so that messages appear
	# in chronological order.
	#
        # Need to be root to use savecore
	/usr/bin/savecore -m
	if [ -r /etc/dumpadm.conf ]; then
		. /etc/dumpadm.conf
		[ -n "$DUMPADM_DEVICE" -a \
		"$DUMPADM_DEVICE" != swap ] && \
		/usr/bin/savecore -m -f $DUMPADM_DEVICE
	fi
fi
if [ ! -f /var/adm/messages ]; then
	/usr/bin/cp /dev/null /var/adm/messages
	/usr/bin/chmod 0644 /var/adm/messages
fi

# Convert the old PID-file based post-command for logadm to an SMF-based one.
TMP_CONF=$(/usr/bin/mktemp /tmp/logadm.conf.XXXXXX)
/usr/bin/sed -e "s|$OLD_METHOD1|$NEW_METHOD|" \
    -e "s|$OLD_METHOD2|$NEW_METHOD|" $LOGADM_CONF > $TMP_CONF
/usr/bin/cmp -s $LOGADM_CONF $TMP_CONF
if [ $? -eq 0 ]; then
	/usr/bin/rm $TMP_CONF
else
	# In case the umask or group is odd.
	mode=$(/usr/bin/stat -c %a $LOGADM_CONF)
	owner_group=$(/usr/bin/stat -c %U:%G $LOGADM_CONF)
	/usr/bin/mv $TMP_CONF $LOGADM_CONF
	/usr/bin/chmod $mode $LOGADM_CONF
	/usr/bin/chown $owner_group $LOGADM_CONF
fi

/usr/lib/rsyslog/rsyslogd >/dev/msglog 2>&1