1 #!/bin/sh 2 # 3 # $NetBSD: swap1,v 1.12 2015/04/20 18:01:46 prlw1 Exp $ 4 # 5 6 # PROVIDE: localswap 7 # REQUIRE: DISKS root 8 # KEYWORD: shutdown 9 10 $_rc_subr_loaded . /etc/rc.subr 11 12 name="swap1" 13 start_cmd="swap1_start" 14 stop_cmd="swap1_stop" 15 16 # Add all block-type swap devices; these might be necessary 17 # during disk checks. 18 # 19 swap1_start() 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 if ! checkyesno no_swap; then 25 swapctl -A -t blk || [ $? = 2 ] 26 fi 27 } 28 29 # Remove all block-type swap devices 30 # 31 swap1_stop() 32 { 33 if checkyesno swapoff || [ -n "$rc_force" ]; then 34 echo "Forcibly unmounting tmpfs filesystems" 35 umount -aft tmpfs 36 echo "Removing block-type swap devices" 37 swapctl -U -t blk || [ $? = 2 ] 38 fi 39 } 40 41 load_rc_config swap 42 run_rc_command "$1" 43