rc.d/addswap: Load the vn(4) module if not already present.
[dragonfly.git] / etc / rc.d / addswap
1 #!/bin/sh
2 #
3 # Add additional swap files
4 #
5 # $FreeBSD: src/etc/rc.d/addswap,v 1.2 2002/10/12 10:31:31 schweikh Exp $
6 #
7
8 # PROVIDE: addswap
9 # REQUIRE: mountcritlocal
10 # BEFORE: sysctl
11
12 . /etc/rc.subr
13
14 name="addswap"
15 start_cmd="addswap_start"
16 stop_cmd=":"
17
18 addswap_start()
19 {
20         case ${swapfile} in
21         [Nn][Oo] | '')
22                 ;;
23         *)
24                 if [ -w "${swapfile}" ]; then
25                         # load vn kernel module if needed
26                         if [ ! -c /dev/vn0 ]; then
27                                 if kldload vn; then
28                                         info 'vn module loaded.'
29                                 else
30                                         err 1 'vn module failed to load.'
31                                 fi
32                         fi
33                         echo "Adding ${swapfile} as additional swap"
34                         vnconfig -e vn0 ${swapfile} swap
35                 fi
36                 ;;
37         esac
38 }
39
40 load_rc_config $name
41 run_rc_command "$1"