Move everything from /var/adm to /var/log
[unleashed/lotheac.git] / usr / src / cmd / syslogd / system-log
bloba94bb18a0e2210a96457410434004a427932d69d
1 #!/bin/sh
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
22 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 # ident "%Z%%M% %I% %E% SMI"
27 OLD_CONF=/etc/default/syslogd
29 . /lib/svc/share/smf_include.sh
31 convert()
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
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;
51 }' ${OLD_CONF} >${OLD_CONF}.new && cp ${OLD_CONF}.new ${OLD_CONF}
52 rm -f ${OLD_CONF}.new
55 if [ ! -f /etc/syslog.conf ]; then
56 echo "/etc/syslog.conf is missing. Exiting."
57 exit $SMF_EXIT_ERR_CONFIG
60 if [ ! -x /usr/sbin/syslogd ]; then
61 echo "Executable /usr/sbin/syslogd not found. Exiting"
62 exit $SMF_EXIT_ERR_CONFIG
65 if smf_is_globalzone; then
67 # Before syslogd starts, save any messages from
68 # previous crash dumps so that messages appear
69 # in chronological order.
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
79 if [ ! -f /var/log/messages ]; then
80 /usr/bin/cp /dev/null /var/log/messages
81 /usr/bin/chmod 0644 /var/log/messages
83 remote=`awk -F= '
84 /^LOG_FROM_REMOTE=[yY][Ee][Ss]/ {print "true"}
85 /^LOG_FROM_REMOTE=[Nn][Oo]/ {print "false"}' < ${OLD_CONF}`
86 case ${remote} in
87 "")
89 "true"|"false")
90 convert ${remote}
93 echo "Unsupported value in for LOG_FROM_REMOTE in ${OLD_CONF}"
94 exit $SMF_EXIT_ERR_CONFIG
96 esac
98 /usr/sbin/syslogd >/dev/msglog 2>&1 &