Print this page
NEX-9586 remove nodename from the default savecore directory path
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/dumpadm/svc-dumpadm
+++ new/usr/src/cmd/dumpadm/svc-dumpadm
1 1 #!/sbin/sh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 #
23 23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 +# Copyright 2017 Nexenta Systems, Inc. All rights reserved.
24 25 #
25 26
26 27 . /lib/svc/share/smf_include.sh
27 28 . /lib/svc/share/fs_include.sh
28 29
29 30 #
30 31 # mksavedir
31 32 # Make sure that $DUMPADM_SAVDIR is set and exists.
32 33 #
33 34 mksavedir ()
34 35 {
35 - [ -z "$DUMPADM_SAVDIR" ] && DUMPADM_SAVDIR=/var/crash/`uname -n`
36 + [ -z "$DUMPADM_SAVDIR" ] && DUMPADM_SAVDIR=/var/crash
36 37 [ -d "$DUMPADM_SAVDIR" ] || /usr/bin/mkdir -m 0700 -p $DUMPADM_SAVDIR
37 38 }
38 39
39 40 #
40 41 # We haven't run savecore on a dump device yet
41 42 #
42 43 savedev=none
43 44
44 45 #
45 46 # If we previously crashed early in boot before dumpadm was used to configure
46 47 # an alternate dump device, then the dump is in the primary swap partition,
47 48 # which was configured as the dump device by the first swapadd early in boot.
48 49 # Thus before we run dumpadm to configure the dump device, we first run
49 50 # savecore to check the swap partition for a dump; this is run in the
50 51 # foreground to reduce the chances of overwriting the dump.
51 52 #
52 53 # This does not apply for zfs root systems that use a zvol for dump;
53 54 # for such systems the dedicated dump device is appointed during startup
54 55 # of the filesystem/usr:default instance before any swap is added.
55 56 # Therefore we must check that the dump device is a swap device here -
56 57 # if not then we'll run savecore here in the foreground and prevent
57 58 # our dependent services coming online until we're done.
58 59 #
59 60
60 61 rootiszfs=0
61 62 alreadydedicated=0
62 63
63 64 readmnttab / </etc/mnttab
64 65 if [ "$fstype" = zfs ] ; then
65 66 rootiszfs=1
66 67 if [ -x /usr/sbin/dumpadm ]; then
67 68 if /usr/sbin/dumpadm 2>/dev/null | grep "Dump device:" | \
68 69 grep '(dedicated)' > /dev/null 2>&1; then
69 70 alreadydedicated=1
70 71 fi
71 72 fi
72 73 fi
73 74
74 75 if [ -x /usr/bin/savecore -a \
75 76 \( ! $rootiszfs -eq 1 -o $alreadydedicated -eq 0 \) ]; then
76 77 [ -r /etc/dumpadm.conf ] && . /etc/dumpadm.conf
77 78
78 79 if [ "x$DUMPADM_ENABLE" != xno ] && mksavedir; then
79 80 /usr/bin/savecore $DUMPADM_SAVDIR
80 81 shift $#
81 82 set -- `/usr/sbin/dumpadm 2>/dev/null | /usr/bin/grep 'device:'`
82 83 savedev=${3:-none}
83 84 else
84 85 #
85 86 # dumpadm -n is in effect, but we can still run savecore
86 87 # to raise an event with initial panic detail extracted
87 88 # from the dump header.
88 89 #
89 90 /usr/bin/savecore -c
90 91 fi
91 92 fi
92 93
93 94 if [ ! -x /usr/bin/savecore ]; then
94 95 echo "WARNING: /usr/bin/savecore is missing or not executable" >& 2
95 96 fi
96 97
97 98 #
98 99 # Now run dumpadm to configure the dump device based on the settings
99 100 # previously saved by dumpadm. See dumpadm(1m) for instructions on
100 101 # how to modify the dump settings.
101 102 #
102 103 if [ -x /usr/sbin/dumpadm ]; then
103 104 /usr/sbin/dumpadm -u || $SMF_EXIT_ERR_CONFIG
104 105 else
105 106 echo "WARNING: /usr/sbin/dumpadm is missing or not executable" >& 2
106 107 exit $SMF_EXIT_ERR_CONFIG
107 108 fi
108 109
109 110 if [ -r /etc/dumpadm.conf ]; then
110 111 . /etc/dumpadm.conf
111 112 else
112 113 echo "WARNING: /etc/dumpadm.conf is missing or unreadable" >& 2
113 114 exit $SMF_EXIT_ERR_CONFIG
114 115 fi
115 116
116 117 #
117 118 # If the savecore executable is absent then we're done
118 119 #
119 120 if [ ! -x /usr/bin/savecore ]; then
120 121 exit $SMF_EXIT_ERR_CONFIG
121 122 fi
122 123
123 124 #
124 125 # Now that dumpadm has reconfigured /dev/dump, we need to run savecore again
125 126 # because the dump device may have changed. If the earlier savecore had
126 127 # saved the dump, savecore will just exit immediately.
127 128 #
128 129
129 130 isswap=0
130 131 swapchanged=0
131 132 if /usr/sbin/swap -l 2>/dev/null | grep "^${DUMPADM_DEVICE} " \
132 133 >/dev/null 2>&1; then
133 134 isswap=1
134 135 if [ "x$savedev" != "x$DUMPADM_DEVICE" ]; then
135 136 swapchanged=1
136 137 fi
137 138 fi
138 139
139 140 if [ "x$DUMPADM_ENABLE" != xno ]; then
140 141 if [ $isswap -eq 1 ]; then
141 142 #
142 143 # If the dump device is part of swap, we only need to run
143 144 # savecore a second time if the device is different from the
144 145 # swap device on which we initially ran savecore.
145 146 #
146 147 if [ $swapchanged -eq 1 ]; then
147 148 mksavedir && /usr/bin/savecore $DUMPADM_SAVDIR &
148 149 fi
149 150 else
150 151 #
151 152 # The dump device couldn't have been dedicated before we
152 153 # ran dumpadm, so we must execute savecore again.
153 154 #
154 155 mksavedir && /usr/bin/savecore $DUMPADM_SAVDIR &
155 156 fi
156 157 else
157 158 #
158 159 # savecore not enabled. Check whether a valid dump is
159 160 # present on the device and raise an event to signal that,
160 161 # but avoid sending a duplicate event from the savecore -c
161 162 # earlier.
162 163 #
163 164 if [ $isswap -eq 0 -o $swapchanged -eq 1 ]; then
164 165 /usr/bin/savecore -c
165 166 fi
166 167 fi
167 168
168 169 exit $SMF_EXIT_OK
|
↓ open down ↓ |
123 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX