Home | History | Annotate | Line # | Download | only in rc.d
      1  1.1    lukem #!/bin/sh
      2  1.1    lukem #
      3  1.8      apb # $NetBSD: swap2,v 1.8 2009/09/24 16:45:48 apb Exp $
      4  1.1    lukem #
      5  1.1    lukem 
      6  1.1    lukem # PROVIDE: nonlocalswap
      7  1.1    lukem # REQUIRE: mountcritremote
      8  1.6  thorpej # BEFORE:  DAEMON
      9  1.1    lukem 
     10  1.7  mycroft $_rc_subr_loaded . /etc/rc.subr
     11  1.1    lukem 
     12  1.1    lukem name="swap2"
     13  1.1    lukem start_cmd="swap2_start"
     14  1.1    lukem 
     15  1.1    lukem swap2_start()
     16  1.1    lukem {
     17  1.8      apb 	# "Critical" file systems are now mounted.  Go ahead and swap
     18  1.8      apb 	# to files now, since they will be residing in the critical file
     19  1.8      apb 	# systems (or, at least, they should be...).
     20  1.1    lukem 	#
     21  1.8      apb 	# Treat exit status 2 from swapctl(8) as successful; it means
     22  1.8      apb 	# "no error, but no suitable swap devices were configured".
     23  1.8      apb 	#
     24  1.8      apb 	# Check for no swap, and warn about it unless that is desired.
     25  1.8      apb 	#
     26  1.8      apb 	local es
     27  1.8      apb 	swapctl -A -t noblk
     28  1.8      apb 	es=$?
     29  1.8      apb 	[ $es = 2 ] && es=0
     30  1.1    lukem 	if ! checkyesno no_swap; then
     31  1.1    lukem 		if swapctl -s | grep "no swap devices configured" > /dev/null;
     32  1.1    lukem 		then
     33  1.1    lukem 			warn "No swap space configured!"
     34  1.8      apb 			es=1
     35  1.1    lukem 		fi
     36  1.1    lukem 	fi
     37  1.8      apb 	return $es
     38  1.1    lukem }
     39  1.1    lukem 
     40  1.1    lukem #		Remove all non-block-type swap devices
     41  1.1    lukem #
     42  1.8      apb stop_cmd="swapctl -U -t noblk || [ $? = 2 ]"
     43  1.1    lukem 
     44  1.4    lukem load_rc_config swap
     45  1.1    lukem run_rc_command "$1"
     46