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