xref: /dragonfly/etc/rc.d/swap1 (revision 35e996c9)
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#
6
7# PROVIDE: localswap
8# REQUIRE: savecore cryptdisks
9# BEFORE:  SERVERS
10# KEYWORD: shutdown
11
12. /etc/rc.subr
13
14name="swap1"
15start_cmd='df_swap1_start'
16stop_cmd=':'
17
18#		Add all block-type swap devices; these might be necessary
19#		during disk checks.
20#
21swap1_start()
22{
23	if ! checkyesno no_swap; then
24		swapctl -A -t blk
25	fi
26}
27
28#		Remove all block-type swap devices
29#
30swap1_stop()
31{
32	if checkyesno swapoff || [ -n "$rc_force" ]; then
33		echo "Removing block-type swap devices"
34		swapctl -U -t blk
35	fi
36}
37
38df_swap1_start()
39{
40	if [ `${SYSCTL_N} vm.swap_enabled` = 0 ]; then
41		return ${RC_CONFIGURED}
42	else
43		swapon -a && return ${RC_CONFIGURED}
44	fi
45	return ${RC_FAILED}
46}
47
48
49load_rc_config swap
50run_rc_command "$1"
51