2004-02-03 11:26:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: disks
|
2004-02-05 21:40:37 +00:00
|
|
|
# REQUIRE: initrandom
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2004-02-03 11:26:08 +00:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
2005-08-05 23:38:51 +00:00
|
|
|
name="encswap"
|
|
|
|
start_cmd="encswap_attach"
|
|
|
|
stop_cmd="encswap_detach"
|
2004-02-03 11:26:08 +00:00
|
|
|
|
2005-08-05 23:38:51 +00:00
|
|
|
encswap_attach()
|
2004-02-03 11:26:08 +00:00
|
|
|
{
|
|
|
|
while read device mountpoint type options rest ; do
|
2004-08-18 21:54:40 +00:00
|
|
|
case ":${device}:${type}:${options}" in
|
|
|
|
:#*)
|
|
|
|
continue
|
|
|
|
;;
|
2004-02-03 11:26:08 +00:00
|
|
|
*.bde:swap:sw)
|
2005-08-05 23:38:51 +00:00
|
|
|
passphrase=`dd if=/dev/random count=1 2>/dev/null | md5 -q`
|
|
|
|
device="${device%.bde}"
|
|
|
|
gbde init "${device}" -P "${passphrase}" || return 1
|
|
|
|
gbde attach "${device}" -p "${passphrase}" || return 1
|
2004-02-03 11:26:08 +00:00
|
|
|
;;
|
2005-08-05 23:38:51 +00:00
|
|
|
*.eli:swap:sw)
|
|
|
|
device="${device%.eli}"
|
|
|
|
geli onetime ${geli_swap_flags} "${device}" || return 1
|
2004-02-03 11:26:08 +00:00
|
|
|
;;
|
|
|
|
esac
|
2004-08-18 21:54:40 +00:00
|
|
|
done < /etc/fstab
|
2004-02-03 11:26:08 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 23:38:51 +00:00
|
|
|
encswap_detach()
|
2004-02-03 11:26:08 +00:00
|
|
|
{
|
|
|
|
while read device mountpoint type options rest ; do
|
2004-08-18 21:54:40 +00:00
|
|
|
case ":${device}:${type}:${options}" in
|
|
|
|
:#*)
|
|
|
|
continue
|
|
|
|
;;
|
2004-02-03 11:26:08 +00:00
|
|
|
*.bde:swap:sw)
|
2005-08-05 23:38:51 +00:00
|
|
|
device="${device%.bde}"
|
|
|
|
gbde detach "${device}"
|
2004-02-03 11:26:08 +00:00
|
|
|
;;
|
2005-08-05 23:38:51 +00:00
|
|
|
*.eli:swap:sw)
|
|
|
|
# Nothing here, because geli swap devices should be
|
|
|
|
# created with the auto-detach-on-last-close option.
|
2004-02-03 11:26:08 +00:00
|
|
|
;;
|
|
|
|
esac
|
2004-08-18 21:54:40 +00:00
|
|
|
done < /etc/fstab
|
2004-02-03 11:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|