xref: /dragonfly/etc/rc.d/swap1 (revision d4ef6694)
1#!/bin/sh
2#
3# $NetBSD: swap1,v 1.8 2002/03/24 15:52:41 lukem Exp $
4# $FreeBSD: src/etc/rc.d/swap1,v 1.3 2002/09/06 16:18:05 gordon Exp $
5# $DragonFly: src/etc/rc.d/swap1,v 1.5 2005/11/19 21:47:32 swildner Exp $
6#
7
8# PROVIDE: localswap
9# REQUIRE: savecore
10# BEFORE:  SERVERS
11# KEYWORD: shutdown
12
13. /etc/rc.subr
14
15name="swap1"
16start_cmd='df_swap1_start'
17stop_cmd=':'
18
19#		Add all block-type swap devices; these might be necessary
20#		during disk checks.
21#
22swap1_start()
23{
24	if ! checkyesno no_swap; then
25		swapctl -A -t blk
26	fi
27}
28
29#		Remove all block-type swap devices
30#
31swap1_stop()
32{
33	if checkyesno swapoff || [ -n "$rc_force" ]; then
34		echo "Removing block-type swap devices"
35		swapctl -U -t blk
36	fi
37}
38
39df_swap1_start()
40{
41	if [ `${SYSCTL_N} vm.swap_enabled` = 0 ]; then
42		return ${RC_CONFIGURED}
43	else
44		swapon -a && return ${RC_CONFIGURED}
45	fi
46	return ${RC_FAILED}
47}
48
49
50load_rc_config swap
51run_rc_command "$1"
52