xref: /illumos-gate/usr/src/cmd/syslogd/system-log (revision bbf215553c7233fbab8a0afdf1fac74c44781867)
17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
66927f468Sdp# Common Development and Distribution License (the "License").
76927f468Sdp# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
226927f468Sdp# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate# Use is subject to license terms.
247c478bd9Sstevel@tonic-gate#
257c478bd9Sstevel@tonic-gate
260ea5e3a5SjjjOLD_CONF=/etc/default/syslogd
270ea5e3a5Sjjj
287c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
297c478bd9Sstevel@tonic-gate
300ea5e3a5Sjjjconvert()
310ea5e3a5Sjjj{
320ea5e3a5Sjjj	svccfg -s svc:/system/system-log setprop config/log_from_remote = $1
330ea5e3a5Sjjj	if [ $? -ne 0 ]; then
340ea5e3a5Sjjj		svccfg -s svc:/system/system-log addpg config application
350ea5e3a5Sjjj		svccfg -s svc:/system/system-log \
360ea5e3a5Sjjj		    addpropvalue config/log_from_remote boolean: $1
370ea5e3a5Sjjj		if [ $? -ne 0 ] ; then
380ea5e3a5Sjjj			echo 'Failed to set remote syslog-logging'
390ea5e3a5Sjjj			exit $SMF_EXIT_ERR_CONFIG
400ea5e3a5Sjjj		fi
410ea5e3a5Sjjj	fi
42*bbf21555SRichard Lowe	echo "Incorporated ${OLD_CONF} settings into SMF. See syslogd(8)."
430ea5e3a5Sjjj	awk '{
440ea5e3a5Sjjj		if ($1 ~ /^LOG_FROM_REMOTE=/) {
450ea5e3a5Sjjj			print "# LOG_FROM_REMOTE is now set using "
46*bbf21555SRichard Lowe			    "svccfg(8), see syslogd(8).";
470ea5e3a5Sjjj		} else {
480ea5e3a5Sjjj			print $0;
490ea5e3a5Sjjj		}
500ea5e3a5Sjjj	}' ${OLD_CONF} >${OLD_CONF}.new && cp ${OLD_CONF}.new ${OLD_CONF}
510ea5e3a5Sjjj	rm -f ${OLD_CONF}.new
520ea5e3a5Sjjj}
530ea5e3a5Sjjj
540ea5e3a5Sjjjif [ ! -f /etc/syslog.conf ]; then
550ea5e3a5Sjjj	echo "/etc/syslog.conf is missing. Exiting."
560ea5e3a5Sjjj	exit $SMF_EXIT_ERR_CONFIG
570ea5e3a5Sjjjfi
580ea5e3a5Sjjj
590ea5e3a5Sjjjif [ ! -x /usr/sbin/syslogd ]; then
600ea5e3a5Sjjj	echo "Executable /usr/sbin/syslogd not found. Exiting"
610ea5e3a5Sjjj	exit $SMF_EXIT_ERR_CONFIG
620ea5e3a5Sjjjfi
630ea5e3a5Sjjj
646927f468Sdpif smf_is_globalzone; then
657c478bd9Sstevel@tonic-gate	#
667c478bd9Sstevel@tonic-gate	# Before syslogd starts, save any messages from
677c478bd9Sstevel@tonic-gate	# previous crash dumps so that messages appear
687c478bd9Sstevel@tonic-gate	# in chronological order.
697c478bd9Sstevel@tonic-gate	#
707c478bd9Sstevel@tonic-gate	/usr/bin/savecore -m
717c478bd9Sstevel@tonic-gate	if [ -r /etc/dumpadm.conf ]; then
727c478bd9Sstevel@tonic-gate		. /etc/dumpadm.conf
737c478bd9Sstevel@tonic-gate		[ -n "$DUMPADM_DEVICE" -a \
747c478bd9Sstevel@tonic-gate	    	"x$DUMPADM_DEVICE" != xswap ] && \
757c478bd9Sstevel@tonic-gate	    	/usr/bin/savecore -m -f $DUMPADM_DEVICE
767c478bd9Sstevel@tonic-gate	fi
777c478bd9Sstevel@tonic-gatefi
787c478bd9Sstevel@tonic-gateif [ ! -f /var/adm/messages ]; then
797c478bd9Sstevel@tonic-gate	/usr/bin/cp /dev/null /var/adm/messages
807c478bd9Sstevel@tonic-gate	/usr/bin/chmod 0644 /var/adm/messages
817c478bd9Sstevel@tonic-gatefi
820ea5e3a5Sjjjremote=`awk -F= '
830ea5e3a5Sjjj	/^LOG_FROM_REMOTE=[yY][Ee][Ss]/ {print "true"}
840ea5e3a5Sjjj	/^LOG_FROM_REMOTE=[Nn][Oo]/     {print "false"}' < ${OLD_CONF}`
850ea5e3a5Sjjjcase ${remote} in
860ea5e3a5Sjjj"")
870ea5e3a5Sjjj    ;;
880ea5e3a5Sjjj"true"|"false")
890ea5e3a5Sjjj    convert ${remote}
900ea5e3a5Sjjj    ;;
910ea5e3a5Sjjj*)
920ea5e3a5Sjjj    echo "Unsupported value in for LOG_FROM_REMOTE in ${OLD_CONF}"
937c478bd9Sstevel@tonic-gate    exit $SMF_EXIT_ERR_CONFIG
940ea5e3a5Sjjj    ;;
950ea5e3a5Sjjjesac
960ea5e3a5Sjjj
970ea5e3a5Sjjj/usr/sbin/syslogd >/dev/msglog 2>&1 &
98