coffin

secure lan file storage on a device
git clone git://parazyd.org/coffin.git
Log | Files | Refs | Submodules | README | LICENSE

mounts (1367B)


      1 #!/usr/bin/env zsh
      2 #
      3 # Copyright (c) 2016 Dyne.org Foundation
      4 # coffin is written and maintained by Ivan J. <parazyd@dyne.org>
      5 #
      6 # This file is part of coffin
      7 #
      8 # This source code is free software: you can redistribute it and/or modify
      9 # it under the terms of the GNU General Public License as published by
     10 # the Free Software Foundation, either version 3 of the License, or
     11 # (at your option) any later version.
     12 #
     13 # This software is distributed in the hope that it will be useful,
     14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 # GNU General Public License for more details.
     17 #
     18 # You should have received a copy of the GNU General Public License
     19 # along with this source code. If not, see <http://www.gnu.org/licenses/>.
     20 
     21 mount-key() {
     22 	fn mount-key $*
     23 	req=(device KEYMOUNT)
     24 	local device="$1"
     25 	ckreq || return 1
     26 
     27 	if [[ -d $KEYMOUNT ]]; then
     28 		die "$KEYMOUNT already exists."
     29 		return 1
     30 	else
     31 		act "Creating $KEYMOUNT"
     32 		mkdir -p $KEYMOUNT
     33 		act "Mounting..."
     34 		mount $device $KEYMOUNT
     35 		return 0
     36 	fi
     37 }
     38 
     39 umount-key() {
     40 	fn umount-key $*
     41 	req=(device KEYMOUNT)
     42 	local device="$1"
     43 	ckreq || return 1
     44 
     45 	if [[ -d $KEYMOUNT ]]; then
     46 		act "Unmounting $device"
     47 		umount $device \
     48 		&& rmdir $KEYMOUNT
     49 		act "Success umounting"
     50 		return 0
     51 	else
     52 		act "No $KEYMOUNT found"
     53 		return 0
     54 	fi
     55 }