encswap revision 225736
1327Sjkh#!/bin/sh 2327Sjkh# 3327Sjkh# $FreeBSD: stable/9/etc/rc.d/encswap 180563 2008-07-16 19:22:48Z dougb $ 4327Sjkh# 5327Sjkh 6327Sjkh# PROVIDE: disks 7327Sjkh# REQUIRE: initrandom 8327Sjkh# KEYWORD: nojail 9327Sjkh 10327Sjkh. /etc/rc.subr 11327Sjkh 12327Sjkhname="encswap" 13327Sjkhstart_cmd="encswap_attach" 14327Sjkhstop_cmd="encswap_detach" 15327Sjkh 16327Sjkhencswap_attach() 17327Sjkh{ 1831997Shoek while read device mountpoint type options rest ; do 19327Sjkh case ":${device}:${type}:${options}" in 20327Sjkh :#*) 21327Sjkh continue 2230221Scharnier ;; 23327Sjkh *.bde:swap:sw) 24327Sjkh passphrase=`dd if=/dev/random count=1 2>/dev/null | md5 -q` 25327Sjkh device="${device%.bde}" 2655567Sphantom gbde init "${device}" -P "${passphrase}" || return 1 2755567Sphantom gbde attach "${device}" -p "${passphrase}" || return 1 2855567Sphantom ;; 2955567Sphantom *.eli:swap:sw) 30327Sjkh device="${device%.eli}" 3155567Sphantom geli onetime ${geli_swap_flags} "${device}" || return 1 3255567Sphantom ;; 33327Sjkh esac 34327Sjkh done < /etc/fstab 35411Sjkh} 36379Sjkh 3711780Sjkhencswap_detach() 38392Sjkh{ 39327Sjkh while read device mountpoint type options rest ; do 4030221Scharnier case ":${device}:${type}:${options}" in 4130221Scharnier :#*) 42327Sjkh continue 43327Sjkh ;; 44327Sjkh *.bde:swap:sw) 45327Sjkh device="${device%.bde}" 46327Sjkh gbde detach "${device}" 4756001Sdan ;; 48327Sjkh *.eli:swap:sw) 49327Sjkh # Nothing here, because geli swap devices should be 5046105Sjkh # created with the auto-detach-on-last-close option. 5146105Sjkh ;; 5246105Sjkh esac 5346105Sjkh done < /etc/fstab 5446105Sjkh} 55327Sjkh 56327Sjkhload_rc_config $name 57327Sjkhrun_rc_command "$1" 58327Sjkh