1 |
c3a56ba9
|
jim-p
|
#!/bin/sh
|
2 |
ac24dc24
|
Renato Botelho
|
#
|
3 |
|
|
# rc.dumpon
|
4 |
|
|
#
|
5 |
|
|
# part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
# Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
# Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
0284d79e
|
jim-p
|
# Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
|
9 |
ac24dc24
|
Renato Botelho
|
# All rights reserved.
|
10 |
|
|
#
|
11 |
|
|
# Based on src/etc/rc.d/dumpon from FreeBSD
|
12 |
|
|
#
|
13 |
b12ea3fb
|
Renato Botelho
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
14 |
|
|
# you may not use this file except in compliance with the License.
|
15 |
|
|
# You may obtain a copy of the License at
|
16 |
ac24dc24
|
Renato Botelho
|
#
|
17 |
b12ea3fb
|
Renato Botelho
|
# http://www.apache.org/licenses/LICENSE-2.0
|
18 |
ac24dc24
|
Renato Botelho
|
#
|
19 |
b12ea3fb
|
Renato Botelho
|
# Unless required by applicable law or agreed to in writing, software
|
20 |
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
21 |
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22 |
|
|
# See the License for the specific language governing permissions and
|
23 |
|
|
# limitations under the License.
|
24 |
27d5c1dd
|
jim-p
|
|
25 |
c3a56ba9
|
jim-p
|
dumpon_try()
|
26 |
|
|
{
|
27 |
|
|
if /sbin/dumpon "${1}" ; then
|
28 |
|
|
# Make a symlink in devfs for savecore
|
29 |
|
|
echo "Using ${1} for dump device."
|
30 |
|
|
ln -fs "${1}" /dev/dumpdev
|
31 |
|
|
return 0
|
32 |
|
|
fi
|
33 |
|
|
echo "Unable to specify $1 as a dump device."
|
34 |
|
|
return 1
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
# Enable dumpdev so that savecore can see it. Enable it
|
38 |
|
|
# early so a crash early in the boot process can be caught.
|
39 |
|
|
#
|
40 |
|
|
while read dev mp type more ; do
|
41 |
|
|
[ "${type}" = "swap" ] || continue
|
42 |
|
|
[ -c "${dev}" ] || continue
|
43 |
|
|
dumpon_try "${dev}" && works=true
|
44 |
|
|
done </etc/fstab
|
45 |
|
|
if [ "${works}" != "true" ]; then
|
46 |
d36e5a49
|
jim-p
|
# fstab entries did not work, try swap labels
|
47 |
|
|
for dev in /dev/label/swap*; do
|
48 |
1b970bb2
|
Luiz Souza
|
if [ ! -e "${dev}" ]; then
|
49 |
|
|
continue;
|
50 |
|
|
fi
|
51 |
d36e5a49
|
jim-p
|
dumpon_try "${dev}" && works=true
|
52 |
|
|
done
|
53 |
|
|
if [ "${works}" != "true" ]; then
|
54 |
|
|
echo "No suitable dump device was found." 1>&2
|
55 |
|
|
exit
|
56 |
|
|
fi
|
57 |
ac24dc24
|
Renato Botelho
|
fi
|