dotfiles

config files and scripts at HOME.
git clone git://git.ricketyspace.net/dotfiles.git
Log | Files | Refs

commit 3f0ebb40ef51316d2e718dca485b60a244c17119
parent 696155f61b3cd50457fd6ba8792749be8c83bf6f
Author: rsiddharth <s@ricketyspace.net>
Date:   Mon, 31 Oct 2016 22:42:31 +0000

Add .bin/m-lo

Script mounts gibberish.

Diffstat:
.bin/m-lo | 44++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)

diff --git a/.bin/m-lo b/.bin/m-lo @@ -0,0 +1,44 @@ +#!/usr/bin/zsh +# +# Copyright (C) 2016 rsiddharth <s@ricketyspace.net> +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program (see COPYING). If not, see +# <http://www.gnu.org/licenses/>. + +# mount file as a loop back device encrypted with cryptsetup +LO_NAME=$1 +LO_FILE_PATH=$2 + +[[ -z $LO_NAME ]] && + echo 'ERROR: Name for lo device not given!' && + exit 1 + + +[[ -z $LO_FILE_PATH || ! -f $LO_FILE_PATH ]] && + echo 'ERROR: File path got fucked!' && + exit 1 + +# get a unused loop device +LO_DEV=$(losetup -f) + +# map file to loop device +losetup $LO_DEV $LO_FILE_PATH + +# open loop back device with cryptsetup +cryptsetup open $LO_DEV $LO_NAME + +# mount it +mkdir -p $HOME/.mnt/$LO_NAME +mnt /dev/mapper/$LO_NAME $HOME/.mnt/$LO_NAME +