Project

General

Profile

Download (1.59 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# rc.dumpon
4
#
5
# part of pfSense (https://www.pfsense.org)
6
# Copyright (c) 2004-2013 BSD Perimeter
7
# Copyright (c) 2013-2016 Electric Sheep Fencing
8
# Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
9
# All rights reserved.
10
#
11
# Based on src/etc/rc.d/dumpon from FreeBSD
12
#
13
# 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
#
17
# http://www.apache.org/licenses/LICENSE-2.0
18
#
19
# 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

    
25
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
	# fstab entries did not work, try swap labels
47
	for dev in /dev/label/swap*; do
48
		if [ ! -e "${dev}" ]; then
49
			continue;
50
		fi
51
		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
fi
(29-29/85)