xref: /onnv-gate/usr/src/cmd/syslogd/system-log (revision 2104:ce72b74b05fd)
10Sstevel@tonic-gate#!/sbin/sh
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
61573Sdp# Common Development and Distribution License (the "License").
71573Sdp# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
221573Sdp# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate# Use is subject to license terms.
240Sstevel@tonic-gate#
250Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
260Sstevel@tonic-gate
27*2104SjjjOLD_CONF=/etc/default/syslogd
28*2104Sjjj
290Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
300Sstevel@tonic-gate
31*2104Sjjjconvert()
32*2104Sjjj{
33*2104Sjjj	svccfg -s svc:/system/system-log setprop config/log_from_remote = $1
34*2104Sjjj	if [ $? -ne 0 ]; then
35*2104Sjjj		svccfg -s svc:/system/system-log addpg config application
36*2104Sjjj		svccfg -s svc:/system/system-log \
37*2104Sjjj		    addpropvalue config/log_from_remote boolean: $1
38*2104Sjjj		if [ $? -ne 0 ] ; then
39*2104Sjjj			echo 'Failed to set remote syslog-logging'
40*2104Sjjj			exit $SMF_EXIT_ERR_CONFIG
410Sstevel@tonic-gate		fi
420Sstevel@tonic-gate	fi
43*2104Sjjj	echo "Incorporated ${OLD_CONF} settings into SMF. See syslogd(1m)."
44*2104Sjjj	awk '{
45*2104Sjjj		if ($1 ~ /^LOG_FROM_REMOTE=/) {
46*2104Sjjj			print "# LOG_FROM_REMOTE is now set using "
47*2104Sjjj			    "svccfg(1m), see syslog(1m).";
48*2104Sjjj		} else {
49*2104Sjjj			print $0;
50*2104Sjjj		}
51*2104Sjjj	}' ${OLD_CONF} >${OLD_CONF}.new && cp ${OLD_CONF}.new ${OLD_CONF}
52*2104Sjjj	rm -f ${OLD_CONF}.new
53*2104Sjjj}
54*2104Sjjj
55*2104Sjjjif [ ! -f /etc/syslog.conf ]; then
56*2104Sjjj	echo "/etc/syslog.conf is missing. Exiting."
57*2104Sjjj	exit $SMF_EXIT_ERR_CONFIG
58*2104Sjjjfi
59*2104Sjjj
60*2104Sjjjif [ ! -x /usr/sbin/syslogd ]; then
61*2104Sjjj	echo "Executable /usr/sbin/syslogd not found. Exiting"
620Sstevel@tonic-gate	exit $SMF_EXIT_ERR_CONFIG
630Sstevel@tonic-gatefi
64*2104Sjjj
65*2104Sjjjif smf_is_globalzone; then
66*2104Sjjj	#
67*2104Sjjj	# Before syslogd starts, save any messages from
68*2104Sjjj	# previous crash dumps so that messages appear
69*2104Sjjj	# in chronological order.
70*2104Sjjj	#
71*2104Sjjj	/usr/bin/savecore -m
72*2104Sjjj	if [ -r /etc/dumpadm.conf ]; then
73*2104Sjjj		. /etc/dumpadm.conf
74*2104Sjjj		[ -n "$DUMPADM_DEVICE" -a \
75*2104Sjjj	    	"x$DUMPADM_DEVICE" != xswap ] && \
76*2104Sjjj	    	/usr/bin/savecore -m -f $DUMPADM_DEVICE
77*2104Sjjj	fi
78*2104Sjjjfi
79*2104Sjjjif [ ! -f /var/adm/messages ]; then
80*2104Sjjj	/usr/bin/cp /dev/null /var/adm/messages
81*2104Sjjj	/usr/bin/chmod 0644 /var/adm/messages
82*2104Sjjjfi
83*2104Sjjjremote=`awk -F= '
84*2104Sjjj	/^LOG_FROM_REMOTE=[yY][Ee][Ss]/ {print "true"}
85*2104Sjjj	/^LOG_FROM_REMOTE=[Nn][Oo]/     {print "false"}' < ${OLD_CONF}`
86*2104Sjjjcase ${remote} in
87*2104Sjjj"")
88*2104Sjjj    ;;
89*2104Sjjj"true"|"false")
90*2104Sjjj    convert ${remote}
91*2104Sjjj    ;;
92*2104Sjjj*)
93*2104Sjjj    echo "Unsupported value in for LOG_FROM_REMOTE in ${OLD_CONF}"
94*2104Sjjj    exit $SMF_EXIT_ERR_CONFIG
95*2104Sjjj    ;;
96*2104Sjjjesac
97*2104Sjjj
98*2104Sjjj/usr/sbin/syslogd >/dev/msglog 2>&1 &
99