On Fri, May 18, 2012 at 6:22 PM, Matthew Monaco <dgbaley27@0x01b.net> wrote:
It seems like some people use this. Use a new variable "tmpfs" to contain the file system type. Default to ext4 (Debian does this). Use the same variable to track the swap option too because we can only do one or the other.
For the record: I don't see the value of this, and think people should use a real tmpfs backed by encrypted swap. That said, if there is demand for it I won't object. Does Debian support choosing your own filesystem or do they always use ext4? Having this be configurable seems a bit over the top to me...
--- cryptmount.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/cryptmount.sh b/cryptmount.sh index 37f5121..5320e3d 100755 --- a/cryptmount.sh +++ b/cryptmount.sh @@ -155,7 +155,7 @@ ct_main() {
# Pre-parse OPTIONS, a little ugly, but it works preparse() { - local args swap + local args tmpfs if ! ct_parse_options $OPTIONS; then error "Invalid options string: $OPTIONS" exit 1 @@ -392,7 +392,7 @@ ct_unmap() {
ct_map() {
- local name="$1" dev="$2" key="$3" args="" swap=0 + local name="$1" dev="$2" key="$3" args="" tmpfs local key_dev="" key_fstype="" key_mntpnt="" key_dev_umount=0 shift 3
@@ -401,7 +401,7 @@ ct_map() { return 1 fi
- # this function sets the args and swap variables + # this function sets the args and tmpfs variables if ! ct_parse_options "$@"; then error "Unable to parse options" return 1 @@ -520,13 +520,20 @@ ct_map() { ret=1 elif run cryptsetup create $key $args "$name" "$dev"; then info "sucessfully mapped '$dev' to '/dev/mapper/$name'" - if [ $swap -eq 1 ]; then + if [ "$tmpfs" = "swap" ]; then if run mkswap -f -L "$name" "/dev/mapper/$name"; then info "mkswap successful on '/dev/mapper/$name'" else error "mkswap failed for '/dev/mapper/$name'" ret=1 fi + elif [ "$tmpfs" ]; then + if run mkfs -t "$tmpfs" "/dev/mapper/$name"; then + info "mkfs successful on '/dev/mapper/$name'" + else + error "mkfs failed for '/dev/mapper/$name'" + ret=1 + fi fi else error "unable to map '$dev' to '/dev/maper/name/$name'" @@ -617,7 +624,7 @@ ct_parse_options() { case "$key" in swap) # set external variable - swap=1 + tmpfs="swap" ;; luks|plain) warn "Ignoring option $key, LUKS volumes are automatically detected" @@ -629,7 +636,9 @@ ct_parse_options() { warn "Ignoring Debian specific option '$key'" ;; tmp) - warn "The tmp= option is not supported" + # set an external variable + [ -z "$val" ] && msg "Defaulting tmp to ext4" + tmpfs="${val:-ext4}" ;; size) args="$args --key-size $val" -- 1.7.10.2