#!/bin/zsh # # Tomb, the Crypto Undertaker # # a tool to easily operate file encryption of private and secret data # # Copyleft (C) 2007-2011 Denis Roio # # This source code is free software; you can redistribute it and/or # modify it under the terms of the GNU Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This source code 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. # Please refer to the GNU Public License for more details. # # You should have received a copy of the GNU Public License along with # this source code; if not, write to: # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # startup wrapper to open tombs echo "arg: $1" try() { which ${1} > /dev/null if [ $? = 0 ]; then return 0; else return -1; fi } # got an argument if [ $1 ]; then # is it a tomb? arg="${1%%\.*}.tomb" if [ -f $arg ]; then file $arg | grep LUKS if [ $? = 0 ]; then # tomb is a valid LUKS file tomb mount $arg if [ $? = 0 ]; then # mount was succesfull (with password and all) # strip extension if there tombname="${arg%%.*}" tombmap=`mount -l | awk "/\[${tombname}\]$/"' { print $1 } '` tombmount=`mount -l | awk "/\[${tombname}\]$/"' { print $3 } '` tomb-status $tombmap $tombname $tombmount &! exit 0 else tomb notify "Tomb cannot open." "Are you knocking the wrong door?" exit 1 fi else tomb notify "Not a real Tomb." "We found no real bones in there." exit 1 fi elif [ -d $1 ]; then # its a directory # FIXME: somehow xdg-open loses mailcap mimes when executed by tomb-status # try xdg-open; if [ $? = 0 ]; then xdg-open ${1}; exit 0; fi try gnome-open; if [ $? = 0 ]; then gnome-open ${1}; exit 0; fi try thunar; if [ $? = 0 ]; then thunar ${1}; exit 0; fi try pcmanfm; if [ $? = 0 ]; then pcmanfm ${1}; exit 0; fi try rox; if [ $? = 0 ]; then rox ${1}; exit 0; fi try fsviewer; if [ $? = 0 ]; then fsviewer ${1}; exit 0; fi # try xnc; if [ $? = 0 ]; then xnc ${1}; exit 0; fi tomb notify "File manager not found." "Tomb cannot guess which filemanager you are using" exit 1 fi fi # no argument but on graphical display: creation dialog if [ -z $DISPLAY ]; then echo "[!] tomb-open is a wrapper for the command 'tomb'" tomb -h exit 1 fi # no arguments: start guided tomb creation tomb notify cat < " read -q if [ $? != 0 ]; then echo "Operation aborted." exit 1 fi # let's proceed echo " Please type in the name for your new tomb file:" echo -n "> " read filename echo " How big you want the Tomb to be?" echo " Type a size number in Megabytes:" echo -n "> " read size echo " You have commanded the creation of this Tomb:" echo " $filename ( $size MBytes )"; echo cat < " read -q if [ $? != 0 ]; then echo "Operation aborted." exit 1 fi cat <