tomb-open: fix wrong functions and indentation

(I love vim = command)
This commit is contained in:
boyska 2012-09-02 12:09:00 +02:00 committed by Jaromil
parent 199ce8008c
commit d117fbd916

View File

@ -76,7 +76,7 @@ Let's start setting your Crypt?"
# so that they are configurable when calling tomb.
ask_usbkey() {
unset usbkey_mount
notice "Waiting 1 minute for a usb key to connect"
say "Waiting 1 minute for a usb key to connect"
act -n "please insert your usb key "
tomb-notify "Insert your USB KEY" \
@ -92,8 +92,7 @@ ask_usbkey() {
c=`expr $c + 1`
if [ $c -gt 60 ]; then
echo
error "timeout."
return 1;
die "timeout"
fi
done
@ -110,9 +109,8 @@ ask_usbkey() {
c=`expr $c + 1`
if [ $c -gt 30 ]; then
echo
error "[!] timeout."
export usbkey_mount=none
return 1;
die "timeout"
fi
done
@ -126,8 +124,7 @@ ask_usbkey() {
if [ -n "$usbpart" ]; then
break
elif [ $i -eq 10 ]; then
error "timeout."
return 1
die "timeout" 1
else
echo -n .
sleep 1
@ -139,8 +136,7 @@ ask_usbkey() {
if [ $? = 0 ]; then
usbmount=$mtmp
else
error "cannot mount usbkey partition $usbmount"
return 1
die "cannot mount usbkey partition $usbmount"
fi
echo
@ -154,8 +150,7 @@ launch_status() {
# applet; it takes the tomb name as an argument and should be
# launched after a successful tomb mount.
if ! [ $1 ]; then
error "cannot launch status tray applet: we don't even know the name of our tomb."
exit 1
die "cannot launch status tray applet: we don't even know the name of our tomb."
fi
if [ $DISPLAY ]; then
@ -190,25 +185,19 @@ if [ $1 ]; then # is it a file?
else
ask_usbkey
if ! [ $usbkey_mount ]; then # no usb key was mounted
error "key not provided for tomb: $tombname"
error "operation aborted." # TODO: dialog with pinentry
exit 1
die "key not provided for tomb $tombname: operation aborted" 1
else # usb mounted, check key presence
if [ -r ${usbkey_mount}/.tomb/${tombname}.tomb.key ]; then
tombkey=${usbkey_mount}/.tomb/${tombname}.tomb.key
elif [ -r ${usbkey_mount}/.tomb ]; then
error "we can't find the right key, have a look yourself:"
ls -lha ${usbkey_mount}/.tomb
exit 1
die "we can't find the right key, have a look yourself:\n$(ls -lha ${usbkey_mount}/.tomb)" 1
else
error "there are no keys stored in your usb"
exit 1
die "there are no keys stored in your usb" 1
fi
fi
fi
if ! [ ${tombkey} ]; then # just to be sure
error "key not found, operation aborted."
exit 1
die "key not found, operation aborted." 1
else
"${TOMBEXEC}" mount -k ${tombkey} ${tombdir}/${tombfile}
@ -253,8 +242,8 @@ fi
# no argument but on graphical display: creation dialog
if [ "$1" != "wizard" ]; then
if [ -z $DISPLAY ]; then
error "tomb-open is a wrapper for the command 'tomb'"
error "[!] type 'tomb-open wizard' if you want to be guided"
no "tomb-open is a wrapper for the command 'tomb'"
no "type 'tomb-open wizard' if you want to be guided"
"${TOMBEXEC}" help
exit 1
fi
@ -267,10 +256,9 @@ if [ -r $HOME/Desktop ]; then
cd $HOME/Desktop;
# or inside HOME
else cd $HOME; fi
notice "Tomb - simple commandline tool for encrypted storage"
act "version $VERSION ($DATE) by Jaromil @ dyne.org"
echo
notice "Guided creation of a new Tomb"
say "Tomb - simple commandline tool for encrypted storage"
say "version $VERSION ($DATE) by Jaromil @ dyne.org"
say "Guided creation of a new Tomb"
cat <<EOF
A Tomb is a special folder that keeps files safe using a password:
@ -291,23 +279,21 @@ EOF
echo -n "> "
read -q
if [ "$?" != 0 ]; then
error "Operation aborted."
exit 1
die "Operation aborted" 1
fi
# let's proceed
notice "Please type in the name for your new tomb file:"
say "Please type in the name for your new tomb file:"
echo -n "> "
read -u 1 tombname
notice "How big you want the Tomb to be?"
say "How big you want the Tomb to be?"
act "Type a size number in Megabytes:"
echo -n "> "
read -u 1 tombsize
if [[ "$tombsize" != <-> ]]; then
error "Only digit allowed! Operation aborted"
exit 1
die "Only digit allowed! Operation aborted"
fi
clear
notice "You have commanded the creation of this Tomb:"
say "You have commanded the creation of this Tomb:"
act "$tombname ( $tombsize MBytes )";
echo
cat <<EOF
@ -325,12 +311,12 @@ cat <<EOF
Considering 1GB takes usually little less than an hour to be digged.
EOF
notice " Digging will take quite some time! Should we start? (y/n)"
say " Digging will take quite some time! Should we start? (y/n)"
echo -n "> "
read -q
if [ $? != 0 ]; then
error "Operation aborted."
exit 1
die "Operation aborted." 1
fi
cat <<EOF
Operation confirmed! we will now call the undertaker to do its job,
@ -341,8 +327,7 @@ tombfile=${tombname}.tomb
"${TOMBEXEC}" create --ignore-swap -s $tombsize ${tombfile}
if [ $? != 0 ]; then
error "An error occurred creating tomb, operation aborted."
exit 1
die "An error occurred creating tomb, operation aborted."
fi
tomb-notify "The Tomb is ready!" "We will now open your new Tomb for the first time."
@ -365,7 +350,7 @@ if [ $? = 0 ]; then
sudo cp -v ${tombfile}.key ${usbkey_mount}/.tomb/
sudo chmod -R go-rwx ${usbkey_mount}/.tomb
notice "${tombname}.key succesfully saved on your USB"
yes "${tombname}.key succesfully saved on your USB"
act "now we'll proceed opening your brand new tomb"
"${TOMBEXEC}" open -k ${tombfile}.key ${tombfile}