encswap revision 148765
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/encswap 148765 2005-08-05 23:38:51Z pjd $ 4# 5 6# PROVIDE: disks 7# REQUIRE: initrandom 8# KEYWORD: nojail 9 10. /etc/rc.subr 11 12name="encswap" 13start_cmd="encswap_attach" 14stop_cmd="encswap_detach" 15 16encswap_attach() 17{ 18 while read device mountpoint type options rest ; do 19 case ":${device}:${type}:${options}" in 20 :#*) 21 continue 22 ;; 23 *.bde:swap:sw) 24 passphrase=`dd if=/dev/random count=1 2>/dev/null | md5 -q` 25 device="${device%.bde}" 26 gbde init "${device}" -P "${passphrase}" || return 1 27 gbde attach "${device}" -p "${passphrase}" || return 1 28 ;; 29 *.eli:swap:sw) 30 device="${device%.eli}" 31 geli onetime ${geli_swap_flags} "${device}" || return 1 32 ;; 33 esac 34 done < /etc/fstab 35} 36 37encswap_detach() 38{ 39 while read device mountpoint type options rest ; do 40 case ":${device}:${type}:${options}" in 41 :#*) 42 continue 43 ;; 44 *.bde:swap:sw) 45 device="${device%.bde}" 46 gbde detach "${device}" 47 ;; 48 *.eli:swap:sw) 49 # Nothing here, because geli swap devices should be 50 # created with the auto-detach-on-last-close option. 51 ;; 52 esac 53 done < /etc/fstab 54} 55 56load_rc_config $name 57run_rc_command "$1" 58