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