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