mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-12-23 02:28:58 +00:00
Cleaning: remove CMD{,2,3} (see #25)
they were deprecated. If you really need, use $PARAM array instead. But you probably DON'T need to; it's better to make your function directly accept parameters (btw, mandatory options should probably be parameters, too)
This commit is contained in:
parent
40af028d8f
commit
2065090b84
54
src/tomb
54
src/tomb
@ -592,9 +592,10 @@ exec_safe_post_hooks() {
|
|||||||
# {{{ TOMB SUB-COMMANDS
|
# {{{ TOMB SUB-COMMANDS
|
||||||
|
|
||||||
# {{{ - Create
|
# {{{ - Create
|
||||||
|
# $1 is the tomb path
|
||||||
|
|
||||||
create_tomb() {
|
create_tomb() {
|
||||||
_message "Commanded to create tomb $CMD2"
|
_message "Commanded to create tomb $1"
|
||||||
if ! option_is_set -f; then check_swap; fi
|
if ! option_is_set -f; then check_swap; fi
|
||||||
|
|
||||||
if ! [ $1 ]; then
|
if ! [ $1 ]; then
|
||||||
@ -1092,13 +1093,14 @@ umount_tomb() {
|
|||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ - Change Password
|
# {{{ - Change Password
|
||||||
|
# $1 is the tomb key path
|
||||||
|
|
||||||
# change tomb key password
|
# change tomb key password
|
||||||
change_passwd() {
|
change_passwd() {
|
||||||
_message "Commanded to change password for tomb key $CMD2"
|
_message "Commanded to change password for tomb key $1"
|
||||||
if ! option_is_set -f; then check_swap; fi
|
if ! option_is_set -f; then check_swap; fi
|
||||||
|
|
||||||
local keyfile="$CMD2"
|
local keyfile="$1"
|
||||||
|
|
||||||
# check the keyfile
|
# check the keyfile
|
||||||
if ! [ -r $keyfile ]; then
|
if ! [ -r $keyfile ]; then
|
||||||
@ -1195,17 +1197,18 @@ change_passwd() {
|
|||||||
# }}}
|
# }}}
|
||||||
# {{{ - Resize
|
# {{{ - Resize
|
||||||
# resize tomb file size
|
# resize tomb file size
|
||||||
|
# $1 is tomb path
|
||||||
resize_tomb() {
|
resize_tomb() {
|
||||||
_message "Commanded to resize tomb $CMD2 to $opts[-s] megabytes"
|
_message "Commanded to resize tomb $1 to $opts[-s] megabytes"
|
||||||
if ! [ ${CMD2} ]; then
|
if ! [ $1 ]; then
|
||||||
_failure "No tomb name specified for resizing"
|
_failure "No tomb name specified for resizing"
|
||||||
elif ! [ -r "${CMD2}" ]; then
|
elif ! [ -r "$1" ]; then
|
||||||
_failure "Cannot find ${CMD2}"
|
_failure "Cannot find $1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local c tombpass tombkey
|
local c tombpass tombkey
|
||||||
local tombfile=`basename ${CMD2}`
|
local tombfile=`basename $1`
|
||||||
local tombdir=`dirname ${CMD2}`
|
local tombdir=`dirname $1`
|
||||||
# make sure the file has a .tomb extension
|
# make sure the file has a .tomb extension
|
||||||
local tombname=${tombfile%%\.*}
|
local tombname=${tombfile%%\.*}
|
||||||
tombfile=${tombname}.tomb
|
tombfile=${tombname}.tomb
|
||||||
@ -1232,7 +1235,7 @@ resize_tomb() {
|
|||||||
|
|
||||||
local tmp_resize=`safe_filename tmbrsz`
|
local tmp_resize=`safe_filename tmbrsz`
|
||||||
local newtombsize=$opts[-s]
|
local newtombsize=$opts[-s]
|
||||||
local oldtombsize=`stat -c %s "${CMD2}" 2>/dev/null`
|
local oldtombsize=`stat -c %s "$1" 2>/dev/null`
|
||||||
local mounted_tomb=`mount -l |
|
local mounted_tomb=`mount -l |
|
||||||
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 }'`
|
awk -vtomb="[$tombname]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 }'`
|
||||||
|
|
||||||
@ -1265,14 +1268,14 @@ resize_tomb() {
|
|||||||
_failure "Error creating the extra resize $tmp_resize, operation aborted."
|
_failure "Error creating the extra resize $tmp_resize, operation aborted."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat "${tmp_resize}" >> "${CMD2}"
|
cat "${tmp_resize}" >> "$1"
|
||||||
${=WIPE} "${tmp_resize}"
|
${=WIPE} "${tmp_resize}"
|
||||||
|
|
||||||
local nstloop=`losetup -f`
|
local nstloop=`losetup -f`
|
||||||
if [ $? = 255 ]; then
|
if [ $? = 255 ]; then
|
||||||
_failure "too many tomb opened. Please close any of them to open another tomb"
|
_failure "too many tomb opened. Please close any of them to open another tomb"
|
||||||
fi
|
fi
|
||||||
losetup -f "${CMD2}"
|
losetup -f "$1"
|
||||||
|
|
||||||
local mapdate=`date +%s`
|
local mapdate=`date +%s`
|
||||||
local mapper="tomb.${tombname}.${mapdate}.`basename $nstloop`"
|
local mapper="tomb.${tombname}.${mapdate}.`basename $nstloop`"
|
||||||
@ -1330,8 +1333,9 @@ resize_tomb() {
|
|||||||
# }}}
|
# }}}
|
||||||
# {{{ - List
|
# {{{ - List
|
||||||
# list all tombs mounted in a readable format
|
# list all tombs mounted in a readable format
|
||||||
|
# $1 is optional, to specify a tomb
|
||||||
list_tombs() {
|
list_tombs() {
|
||||||
if [ $CMD2 ]; then
|
if [ $1 ]; then
|
||||||
# list a specific tomb
|
# list a specific tomb
|
||||||
mounted_tombs=`mount -l |
|
mounted_tombs=`mount -l |
|
||||||
awk -vtomb="[$1]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 ";" $3 ";" $5 ";" $6 ";" $7 }'`
|
awk -vtomb="[$1]" '/^\/dev\/mapper\/tomb/ { if($7==tomb) print $1 ";" $3 ";" $5 ";" $6 ";" $7 }'`
|
||||||
@ -1348,7 +1352,7 @@ list_tombs() {
|
|||||||
|
|
||||||
if ! [ $mounted_tombs ]; then
|
if ! [ $mounted_tombs ]; then
|
||||||
if [ $1 ]; then
|
if [ $1 ]; then
|
||||||
die "There seems to be no open tomb engraved as [$CMD2]"
|
die "There seems to be no open tomb engraved as [$1]"
|
||||||
else
|
else
|
||||||
die "I can't see any open tomb, may they all rest in peace."
|
die "I can't see any open tomb, may they all rest in peace."
|
||||||
fi
|
fi
|
||||||
@ -1686,10 +1690,6 @@ main() {
|
|||||||
autoload colors; colors
|
autoload colors; colors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CMD=$subcommand
|
|
||||||
CMD2=$PARAM[1]
|
|
||||||
CMD3=$PARAM[2]
|
|
||||||
|
|
||||||
xxx "Tomb command: $subcommand ${PARAM}"
|
xxx "Tomb command: $subcommand ${PARAM}"
|
||||||
|
|
||||||
case "$subcommand" in
|
case "$subcommand" in
|
||||||
@ -1704,17 +1704,17 @@ main() {
|
|||||||
umount|close|slam)
|
umount|close|slam)
|
||||||
check_priv
|
check_priv
|
||||||
[ "$subcommand" = "slam" ] && SLAM=1
|
[ "$subcommand" = "slam" ] && SLAM=1
|
||||||
umount_tomb ${CMD2}
|
umount_tomb $PARAM[1]
|
||||||
;;
|
;;
|
||||||
passwd)
|
passwd)
|
||||||
check_priv
|
check_priv
|
||||||
change_passwd ${CMD2}
|
change_passwd $PARAM[1]
|
||||||
;;
|
;;
|
||||||
list)
|
list)
|
||||||
list_tombs ${CMD2}
|
list_tombs $PARAM[1]
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
launch_status ${CMD2}
|
launch_status $PARAM[1]
|
||||||
;;
|
;;
|
||||||
help)
|
help)
|
||||||
usage
|
usage
|
||||||
@ -1724,24 +1724,24 @@ main() {
|
|||||||
_warning "steghide not installed. Cannot bury your key"
|
_warning "steghide not installed. Cannot bury your key"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
encode_key ${CMD2} ${CMD3}
|
encode_key $PARAM[1] $PARAM[2]
|
||||||
;;
|
;;
|
||||||
exhume)
|
exhume)
|
||||||
if [ "$STEGHIDE" = 0 ]; then
|
if [ "$STEGHIDE" = 0 ]; then
|
||||||
_warning "steghide not installed. Cannot exhume your key"
|
_warning "steghide not installed. Cannot exhume your key"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
decode_key ${CMD2} ${CMD3}
|
decode_key $PARAM[1] $PARAM[2]
|
||||||
;;
|
;;
|
||||||
resize)
|
resize)
|
||||||
check_priv
|
check_priv
|
||||||
resize_tomb
|
resize_tomb $PARAM[1]
|
||||||
;;
|
;;
|
||||||
# internal commands useful to developers
|
# internal commands useful to developers
|
||||||
'source') return 0 ;;
|
'source') return 0 ;;
|
||||||
install) check_priv ; install_tomb ;;
|
install) check_priv ; install_tomb ;;
|
||||||
askpass) ask_password ${CMD2} ${CMD3} ;;
|
askpass) ask_password $PARAM[1] $PARAM[2] ;;
|
||||||
mktemp) safe_dir ${CMD2} ;;
|
mktemp) safe_dir $PARAM[1] ;;
|
||||||
translate) generate_translatable_strings ;;
|
translate) generate_translatable_strings ;;
|
||||||
__default)
|
__default)
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user