xref: /dragonfly/etc/rc.d/swap1 (revision 4caa7869)
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.3 2003/12/14 19:13:15 dillon Exp $
6#
7
8# PROVIDE: localswap
9# REQUIRE: disks
10# KEYWORD: DragonFly FreeBSD NetBSD shutdown
11
12. /etc/rc.subr
13
14name="swap1"
15
16case ${OSTYPE} in
17DragonFly)
18	start_cmd='df_swap1_start'
19	stop_cmd=':'
20	;;
21FreeBSD)
22	start_cmd='swapon -a'
23	stop_cmd=':'
24	;;
25NetBSD)
26	#	Add all block-type swap devices; these might be necessary
27	#	during disk checks.
28	#
29	start_cmd="swap1_start"
30	stop_cmd="swap1_stop"
31	;;
32esac
33
34#		Add all block-type swap devices; these might be necessary
35#		during disk checks.
36#
37swap1_start()
38{
39	if ! checkyesno no_swap; then
40		swapctl -A -t blk
41	fi
42}
43
44#		Remove all block-type swap devices
45#
46swap1_stop()
47{
48	if checkyesno swapoff || [ -n "$rc_force" ]; then
49		echo "Removing block-type swap devices"
50		swapctl -U -t blk
51	fi
52}
53
54df_swap1_start()
55{
56	if [ `${SYSCTL_N} vm.swap_enabled` = 0 ]; then
57		return ${RC_CONFIGURED}
58	else
59		swapon -a && return ${RC_CONFIGURED}
60	fi
61	return ${RC_FAILED}
62}
63
64
65load_rc_config swap
66run_rc_command "$1"
67