xref: /titanic_50/usr/src/cmd/syslogd/system-log (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
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 (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 2006 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26
27OLD_CONF=/etc/default/syslogd
28
29. /lib/svc/share/smf_include.sh
30
31convert()
32{
33	svccfg -s svc:/system/system-log setprop config/log_from_remote = $1
34	if [ $? -ne 0 ]; then
35		svccfg -s svc:/system/system-log addpg config application
36		svccfg -s svc:/system/system-log \
37		    addpropvalue config/log_from_remote boolean: $1
38		if [ $? -ne 0 ] ; then
39			echo 'Failed to set remote syslog-logging'
40			exit $SMF_EXIT_ERR_CONFIG
41		fi
42	fi
43	echo "Incorporated ${OLD_CONF} settings into SMF. See syslogd(1m)."
44	awk '{
45		if ($1 ~ /^LOG_FROM_REMOTE=/) {
46			print "# LOG_FROM_REMOTE is now set using "
47			    "svccfg(1m), see syslog(1m).";
48		} else {
49			print $0;
50		}
51	}' ${OLD_CONF} >${OLD_CONF}.new && cp ${OLD_CONF}.new ${OLD_CONF}
52	rm -f ${OLD_CONF}.new
53}
54
55if [ ! -f /etc/syslog.conf ]; then
56	echo "/etc/syslog.conf is missing. Exiting."
57	exit $SMF_EXIT_ERR_CONFIG
58fi
59
60if [ ! -x /usr/sbin/syslogd ]; then
61	echo "Executable /usr/sbin/syslogd not found. Exiting"
62	exit $SMF_EXIT_ERR_CONFIG
63fi
64
65if smf_is_globalzone; then
66	#
67	# Before syslogd starts, save any messages from
68	# previous crash dumps so that messages appear
69	# in chronological order.
70	#
71	/usr/bin/savecore -m
72	if [ -r /etc/dumpadm.conf ]; then
73		. /etc/dumpadm.conf
74		[ -n "$DUMPADM_DEVICE" -a \
75	    	"x$DUMPADM_DEVICE" != xswap ] && \
76	    	/usr/bin/savecore -m -f $DUMPADM_DEVICE
77	fi
78fi
79if [ ! -f /var/adm/messages ]; then
80	/usr/bin/cp /dev/null /var/adm/messages
81	/usr/bin/chmod 0644 /var/adm/messages
82fi
83remote=`awk -F= '
84	/^LOG_FROM_REMOTE=[yY][Ee][Ss]/ {print "true"}
85	/^LOG_FROM_REMOTE=[Nn][Oo]/     {print "false"}' < ${OLD_CONF}`
86case ${remote} in
87"")
88    ;;
89"true"|"false")
90    convert ${remote}
91    ;;
92*)
93    echo "Unsupported value in for LOG_FROM_REMOTE in ${OLD_CONF}"
94    exit $SMF_EXIT_ERR_CONFIG
95    ;;
96esac
97
98/usr/sbin/syslogd >/dev/msglog 2>&1 &
99