tdelete and backup hooks - coffin - secure lan file storage on a device HTML git clone git://parazyd.org/coffin.git DIR Log DIR Files DIR Refs DIR Submodules DIR README DIR LICENSE --- DIR commit 4ed8184a04fbe3d750f461c2329fafd095836c4b DIR parent 6ec7e0052c655bc22f8e62adadfadaef41f07040 HTML Author: parazyd <parazyd@dyne.org> Date: Mon, 7 Mar 2016 15:47:50 +0100 delete and backup hooks Diffstat: A gmakehook | 481 +++++++++++++++++++++++++++++++ D makehook.sh | 360 ------------------------------- 2 files changed, 481 insertions(+), 360 deletions(-) --- DIR diff --git a/gmakehook b/gmakehook t@@ -0,0 +1,481 @@ +#!/usr/bin/env zsh +# +# Zenity helper script to make tombox hooks more user-friendly +# +# ~ parazyd + +typeset -H UNDERTAKER +typeset -H TOMBSIZE +typeset -H TOMBNAME +typeset -H sudoassword + +keymount="/media/tombkey" +coffindot="$keymount/.coffin" +hooks="$coffindot/hook" + +# {{{ icon +MONMORT="/tmp/monmort.png" +ICONB64="iVBORw0KGgoAAAANSUhEUgAAACAAAAAgEAQAAACJ4248AAAAAmJLR0T//xSrMc0AAAAJcEhZcwAA +AEgAAABIAEbJaz4AAAAJdnBBZwAAACAAAAAgAIf6nJ0AAADrSURBVFjD5ZZBEsMgCEU/TO/l2XMx +04VjQ1K1CDYswkwWJnH+E/EL4RP7jluDCACoim/bvfIpFQiKEJcQHCN9xEtLCgDMQM7f33sZrPNG +/05loCXujfAtCAVgNgLwIuycjQAra8G9Fm823ADabPRA1QDelfZAVUZktWrNvL8ew5YTnsStx3Am +AyOInJVbYF1prZuU+tsR1g9UMDqGuo5oFWhtSEQNEGmeVrqv73Tj0pIZirANMYqRhyw5Bb9MauSW +SwA8l9OzG5LnAsiiDQGQRRvaEwInK54J390hndAIYIeQ4k6AAjE/h06ab0SjP08MA1xDAAAAJXRF +WHRkYXRlOmNyZWF0ZQAyMDExLTAxLTEyVDA5OjM0OjI0KzAxOjAwo//d7wAAACV0RVh0ZGF0ZTpt +b2RpZnkAMjAxMS0wMS0xMlQwOTozNDoyNCswMTowMNKiZVMAAAAASUVORK5CYII=" +print "$ICONB64" | base64 --decode > $MONMORT +# }}} + +# {{{ sudo functions +function _sudo { + sudoassword=$(ask_password "Insert sudo password for user $USER") + print "$sudoassword\n" | sudo -S -v + _sudowrong +} +function _sudowrong { + if [[ $? == 1 ]]; then + sudoassword=$(ask_password "Wrong password. Insert sudo password for user $USER") + print "$sudoassword\n" | sudo -S -v + _sudowrong + fi +} +# }}} + +# {{{ Some pinentry code shamelessly stolen from tomb +# Ask user for a password +# Wraps around the pinentry command, from the GnuPG project, as it +# provides better security and conveniently use the right toolkit. +ask_password() { + local description="$1" + local title="${2:-Enter tomb password.}" + local output + local password + local gtkrc + local theme + + # Distributions have broken wrappers for pinentry: they do + # implement fallback, but they disrupt the output somehow. We are + # better off relying on less intermediaries, so we implement our + # own fallback mechanisms. Pinentry supported: curses, gtk-2, qt4 + # and x11. + + # make sure LANG is set, default to C + LANG=${LANG:-C} + + + if [[ "$DISPLAY" = "" ]]; then + + if _is_found "pinentry-curses"; then + output=`cat <<EOF | pinentry-curses +OPTION ttyname=$TTY +OPTION lc-ctype=$LANG +SETTITLE $title +SETDESC $description +SETPROMPT Password: +GETPIN +EOF` + fi + + else # a DISPLAY is found to be active + + # customized gtk2 dialog with a skull (if extras are installed) + if _is_found "pinentry-gtk-2"; then + + gtkrc="" + theme=/share/themes/tomb/gtk-2.0-key/gtkrc + for i in /usr/local /usr; do + [[ -r $i/$theme ]] && { + gtkrc="$i/$theme" + break + } + done + [[ "$gtkrc" = "" ]] || { + gtkrc_old="$GTK2_RC_FILES" + export GTK2_RC_FILES="$gtkrc" + } + output=`cat <<EOF | pinentry-gtk-2 +OPTION ttyname=$TTY +OPTION lc-ctype=$LANG +SETTITLE $title +SETDESC $description +SETPROMPT Password: +GETPIN +EOF` + [[ "$gtkrc" = "" ]] || export GTK2_RC_FILES="$gtkrc_old" + + # TODO QT4 customization of dialog + elif _is_found "pinentry-qt4"; then + + # TODO X11 customization of dialog + elif _is_found "pinentry-x11"; then + + output=`cat <<EOF | pinentry-x11 +OPTION ttyname=$TTY +OPTION lc-ctype=$LANG +SETTITLE $title +SETDESC $description +SETPROMPT Password: +GETPIN +EOF` + + else + + if _is_found "pinentry-curses"; then + + output=`cat <<EOF | pinentry-curses +OPTION ttyname=$TTY +OPTION lc-ctype=$LANG +SETTITLE $title +SETDESC $description +SETPROMPT Password: +GETPIN +EOF` + else + fi + + fi + + fi # end of DISPLAY block + + # parse the pinentry output + for i in ${(f)output}; do + [[ "$i" =~ "^ERR.*" ]] && { + print "canceled" + return 1 } + + # here the password is found + [[ "$i" =~ "^D .*" ]] && password="${i##D }" + done + + [[ "$password" = "" ]] && { + print "empty" + return 1 } + + print "$password" + return 0 +} + +_is_found() { + # returns 0 if binary is found in path + [[ "$1" = "" ]] && return 1 + command -v "$1" 1>/dev/null 2>/dev/null + return $? +} +# }}} + +# {{{ _clean - Clean function, removes sensitive stuff from memory +function _clean { + TOMBSIZE="$rr"; unset TOMBSIZE + TOMBNAME="$rr"; unset TOMBNAME + UNDERTAKER="$rr"; unset UNDERTAKER + sudoassword="$rr"; unset sudoassword +} +# }}} + +# {{{ zenity dialogs +function _zenques { + zenity \ + --window-icon="$MONMORT" \ + --question \ + --text="$1" +} +function _zenwarn { + zenity \ + --window-icon="$MONMORT" \ + --warning \ + --title="$1" \ + --text="$2" +} +function _zeninfo { + zenity \ + --window-icon="$MONMORT" \ + --info \ + --title="$1" \ + --text="$2" +} +function _zenerr { + zenity \ + --window-icon="$MONMORT" \ + --error \ + --title="$1" \ + --text="$2" +} +function _zenentry { + zenity \ + --window-icon="$MONMORT" \ + --entry \ + --title="$1" \ + --text="$2" \ + --entry-text="$3" +} +# }}} + +function _umountkey { sudo umount $keymount && sudo rmdir $keymount } +function _mountkey { + sudo umount $USBKEY + if [[ $? = 1 ]]; then + _zenerr "Error" "Your key is mounted somewhere and I've run into issues. Please unmount it and re-run." + _clean && exit + fi + if [[ -d $keymount ]]; then + _zenwarn "Warning" "Something is already mounted on $keymount. Please check and re-run." + _clean && exit + fi + + sudo mkdir -p $keymount + sudo mount $USBKEY $keymount + + if ! [[ -d $coffindot ]]; then + sudo mkdir $coffindot + fi +} + +function _main { + _clean + cmnd=$(zenity \ + --window-icon="$MONMORT" \ + --title="tombox hook helper" \ + --list \ + --hide-header \ + --text="tombox hook helper\nChoose what hook you want to create:" \ + --separator=" # " \ + --column=Function \ + --column=Description \ + "create" "a new tomb on the tombox" \ + "delete" "a tomb from the tombox" \ + "backup" "a tomb from the tombox" \ + "foobar" "on the tombox") + eval "_$cmnd" +} + +# {{{ _create +function _create { + vars=$(zenity \ + --window-icon="$MONMORT" \ + --title="Create a new tomb" \ + --forms \ + --text="Enter the info for your new tomb" \ + --separator=":" \ + --add-entry="Tombox username" \ + --add-entry="Tomb name" \ + --add-entry="Tomb's size in MiB") + if [[ $? = 1 ]]; then + exec _main + else + UNDERTAKER=${vars[(ws@:@)1]} + re='^[A-Za-z0-9]+$' + if ! [[ $UNDERTAKER =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in username!" + exec _create + fi + TOMBNAME=${vars[(ws@:@)2]} + if ! [[ $TOMBNAME =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in tomb name!" + exec _create + fi + TOMBSIZE=${vars[(ws@:@)3]} + re='^[0-9]+$' + if ! [[ $TOMBSIZE =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in tomb size!" + exec _create + fi + fi + + feats=$(zenity \ + --window-icon="$MONMORT" \ + --title="Choose features" \ + --text="Choose features you wish to include with your tomb" \ + --list \ + --checklist \ + --separator=":" \ + --column=Yes/No \ + --column=Feature \ + "FALSE" "webdav" \ + "FALSE" "sshfs" \ + "FALSE" "ipfs") + if [[ $? = 1 ]]; then; exec _main; fi + + TOMBHOOKS=$(_zenques "Choose 'Yes' if you want to edit your tomb's bind-hooks and post-hooks") + if [[ $? = 0 ]]; then + bindhook=$(zenity \ + --window-icon="$MONMORT" \ + --title="bind-hooks" \ + --checkbox="Accept these bind-hooks" \ + --text-info \ + --editable) + if [[ $? = 1 ]]; then; exec _main; fi + + posthook=$(zenity \ + --window-icon="$MONMORT" \ + --title="post-hooks" \ + --checkbox="Accept these post-hooks" \ + --text-info \ + --editable) + if [[ $? = 1 ]]; then; exec _main; fi + fi + + _zeninfo "gmakehook" "Plug in your USB key and click OK." + lsblk -npl | awk -F" " '{print $1 " " $4}' | grep '^/dev/sd.. ' > ./.devs + + USBKEY=$(zenity \ + --window-icon="$MONMORT" \ + --title="Choose USB key" \ + --list \ + --text="Choose your USB key to use" \ + --separator=" " \ + --column="Device path" \ + --column="Device size" \ + $(cat ./.devs)) + if [[ $? = 1 ]]; then; exec _main; fi + + _sudo + _mountkey + if [[ -f $hooks ]]; then + _zenques "Warning! There is already an existing hook. Do you want to overwrite?" + if [[ $? = 1 ]]; then + _zeninfo "gmakehook" "Postponing..." && _umountkey && exec _main + else + print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks + if [[ -n $bindhook ]]; then + print "$bindhook" | sudo tee $coffindot/bindhooks + fi + if [[ -n $posthook ]]; then + print "$posthook" | sudo tee $coffindot/posthooks + fi + _umountkey && _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in a tombox to activate it." + exec _main + fi + else + print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks + if [[ -n $bindhook ]]; then + print "$bindhook" | sudo tee $coffindot/bindhooks + fi + if [[ -n $posthook ]]; then + print "$posthook" | sudo tee $coffindot/posthooks + fi + _umountkey && _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in the tombox to activate it." + exec _main + fi +} +# }}} + +# {{{ _delete +function _delete { + vars=$(zenity \ + --window-icon="$MONMORT" \ + --title="Delete an existing tomb" \ + --forms \ + --text="Enter the info of your tomb" \ + --separator=":" \ + --add-entry="Tombox username" \ + --add-entry="Tomb name") + if [[ $? = 1 ]]; then + exec _main + else + UNDERTAKER=${vars[(ws@:@)1]} + re='^[A-Za-z0-9]+$' + if ! [[ $UNDERTAKER =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in username!" + exec _delete + fi + TOMBNAME=${vars[(ws@:@)2]} + if ! [[ $TOMBNAME =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in tomb name!" + exec _delete + fi + fi + + _zeninfo "gmakehook" "Plug in your USB key and click OK." + lsblk -npl | awk -F" " '{print $1 " " $4}' | grep '^/dev/sd.. ' > ./.devs + + USBKEY=$(zenity \ + --window-icon="$MONMORT" \ + --title="Choose USB key" \ + --list \ + --text="Choose your USB key to use" \ + --separator=" " \ + --column="Device path" \ + --column="Device size" \ + $(cat ./.devs)) + if [[ $? = 1 ]]; then; exec _main; fi + + _sudo + _mountkey + if [[ -f $hooks ]]; then + _zenques "Warning! There is already an existing hook. Do you want to overwrite?" + if [[ $? = 1 ]]; then + _zeninfo "gmakehook" "Postponing..." && _umountkey && exec _main + else + print "delete:${UNDERTAKER}:${TOMBNAME}" | sudo tee $hooks + _umountkey && _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in a tombox to activate it." + exec _main + fi + else + print "delete:${UNDERTAKER}:${TOMBNAME}" | sudo tee $hooks + _umountkey && _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in the tombox to activate it." + exec _main + fi +} +# }}} + +# {{{ _backup +function _backup { + vars=$(zenity \ + --window-icon="$MONMORT" \ + --title="Backup an existing tomb" \ + --forms \ + --text="Enter the info of your tomb" \ + --separator=":" \ + --add-entry="Tombox username" \ + --add-entry="Tomb name") + if [[ $? = 1 ]]; then + exec _main + else + UNDERTAKER=${vars[(ws@:@)1]} + re='^[A-Za-z0-9]+$' + if ! [[ $UNDERTAKER =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in username!" + exec _delete + fi + TOMBNAME=${vars[(ws@:@)2]} + if ! [[ $TOMBNAME =~ $re ]]; then + _zenwarn "Warning" "Invalid characters in tomb name!" + exec _delete + fi + fi + + _zeninfo "gmakehook" "Plug in your USB key and click OK." + lsblk -npl | awk -F" " '{print $1 " " $4}' | grep '^/dev/sd.. ' > ./.devs + + USBKEY=$(zenity \ + --window-icon="$MONMORT" \ + --title="Choose USB key" \ + --list \ + --text="Choose your USB key to use" \ + --separator=" " \ + --column="Device path" \ + --column="Device size" \ + $(cat ./.devs)) + if [[ $? = 1 ]]; then; exec _main; fi + + _sudo + _mountkey + if [[ -f $hooks ]]; then + _zenques "Warning! There is already an existing hook. Do you want to overwrite?" + if [[ $? = 1 ]]; then + _zeninfo "gmakehook" "Postponing..." && _umountkey && exec _main + else + print "backup:${UNDERTAKER}:${TOMBNAME}" | sudo tee $hooks + _umountkey && _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in a tombox to activate it." + exec _main + fi + else + print "backup:${UNDERTAKER}:${TOMBNAME}" | sudo tee $hooks + _umountkey && _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in the tombox to activate it." + exec _main + fi +} +# }}} + +function _ { rm ./.devs } +exec _main DIR diff --git a/makehook.sh b/makehook.sh t@@ -1,360 +0,0 @@ -#!/usr/bin/env zsh -# -# Zenity helper script to make tombox hooks more user-friendly -# -# ~ parazyd - -typeset -H UNDERTAKER -typeset -H TOMBPASS -typeset -H TOMBSIZE -typeset -H TOMBNAME -typeset -H sudoassword - -keymount="/media/tombkey" -coffindot="$keymount/.coffin" -hooks="$coffindot/hook" - -lsblk -npl | awk -F" " '{print $1}' | grep ^/dev/sd.. > ./.devs - -# {{{ icon -MONMORT="/tmp/monmort.png" -ICONB64="iVBORw0KGgoAAAANSUhEUgAAACAAAAAgEAQAAACJ4248AAAAAmJLR0T//xSrMc0AAAAJcEhZcwAA\n -AEgAAABIAEbJaz4AAAAJdnBBZwAAACAAAAAgAIf6nJ0AAADrSURBVFjD5ZZBEsMgCEU/TO/l2XMx\n -04VjQ1K1CDYswkwWJnH+E/EL4RP7jluDCACoim/bvfIpFQiKEJcQHCN9xEtLCgDMQM7f33sZrPNG\n -/05loCXujfAtCAVgNgLwIuycjQAra8G9Fm823ADabPRA1QDelfZAVUZktWrNvL8ew5YTnsStx3Am\n -AyOInJVbYF1prZuU+tsR1g9UMDqGuo5oFWhtSEQNEGmeVrqv73Tj0pIZirANMYqRhyw5Bb9MauSW\n -SwA8l9OzG5LnAsiiDQGQRRvaEwInK54J390hndAIYIeQ4k6AAjE/h06ab0SjP08MA1xDAAAAJXRF\n -WHRkYXRlOmNyZWF0ZQAyMDExLTAxLTEyVDA5OjM0OjI0KzAxOjAwo//d7wAAACV0RVh0ZGF0ZTpt\n -b2RpZnkAMjAxMS0wMS0xMlQwOTozNDoyNCswMTowMNKiZVMAAAAASUVORK5CYII=" -echo -e "$ICONB64" | base64 --decode > $MONMORT -# }}} - -# {{{ sudo functions -function _sudo { - sudoassword=$(ask_password "Insert sudo password for user $USER") - echo -e "$sudoassword\n" | sudo -S -v - _sudowrong -} -function _sudowrong { - if [[ $? == 1 ]]; then - sudoassword=$(ask_password "Wrong password. Insert sudo password for user $USER") - echo -e "$sudoassword\n" | sudo -S -v - _sudowrong - fi -} -# }}} - -# {{{ Some pinentry code shamelessly stolen from tomb -# Ask user for a password -# Wraps around the pinentry command, from the GnuPG project, as it -# provides better security and conveniently use the right toolkit. -ask_password() { - local description="$1" - local title="${2:-Enter tomb password.}" - local output - local password - local gtkrc - local theme - - # Distributions have broken wrappers for pinentry: they do - # implement fallback, but they disrupt the output somehow. We are - # better off relying on less intermediaries, so we implement our - # own fallback mechanisms. Pinentry supported: curses, gtk-2, qt4 - # and x11. - - # make sure LANG is set, default to C - LANG=${LANG:-C} - - - if [[ "$DISPLAY" = "" ]]; then - - if _is_found "pinentry-curses"; then - output=`cat <<EOF | pinentry-curses -OPTION ttyname=$TTY -OPTION lc-ctype=$LANG -SETTITLE $title -SETDESC $description -SETPROMPT Password: -GETPIN -EOF` - fi - - else # a DISPLAY is found to be active - - # customized gtk2 dialog with a skull (if extras are installed) - if _is_found "pinentry-gtk-2"; then - - gtkrc="" - theme=/share/themes/tomb/gtk-2.0-key/gtkrc - for i in /usr/local /usr; do - [[ -r $i/$theme ]] && { - gtkrc="$i/$theme" - break - } - done - [[ "$gtkrc" = "" ]] || { - gtkrc_old="$GTK2_RC_FILES" - export GTK2_RC_FILES="$gtkrc" - } - output=`cat <<EOF | pinentry-gtk-2 -OPTION ttyname=$TTY -OPTION lc-ctype=$LANG -SETTITLE $title -SETDESC $description -SETPROMPT Password: -GETPIN -EOF` - [[ "$gtkrc" = "" ]] || export GTK2_RC_FILES="$gtkrc_old" - - # TODO QT4 customization of dialog - elif _is_found "pinentry-qt4"; then - - # TODO X11 customization of dialog - elif _is_found "pinentry-x11"; then - - output=`cat <<EOF | pinentry-x11 -OPTION ttyname=$TTY -OPTION lc-ctype=$LANG -SETTITLE $title -SETDESC $description -SETPROMPT Password: -GETPIN -EOF` - - else - - if _is_found "pinentry-curses"; then - - output=`cat <<EOF | pinentry-curses -OPTION ttyname=$TTY -OPTION lc-ctype=$LANG -SETTITLE $title -SETDESC $description -SETPROMPT Password: -GETPIN -EOF` - else - fi - - fi - - fi # end of DISPLAY block - - # parse the pinentry output - for i in ${(f)output}; do - [[ "$i" =~ "^ERR.*" ]] && { - print "canceled" - return 1 } - - # here the password is found - [[ "$i" =~ "^D .*" ]] && password="${i##D }" - done - - [[ "$password" = "" ]] && { - print "empty" - return 1 } - - print "$password" - return 0 -} - -_is_found() { - # returns 0 if binary is found in path - [[ "$1" = "" ]] && return 1 - command -v "$1" 1>/dev/null 2>/dev/null - return $? -} -# }}} - -# {{{ _clean - Clean function, removes sensitive stuff from memory -function _clean { - unset $? - local rr="$RANDOM" - while [[ ${#rr} -lt 500 ]]; do - rr+="$RANDOM" - done - TOMBPASS="$rr"; unset TOMBPASS - TOMBSIZE="$rr"; unset TOMBSIZE - TOMBNAME="$rr"; unset TOMBNAME - UNDERTAKER="$rr"; unset UNDERTAKER - happenz="$rr"; unset happenz - sudoassword="$rr"; unset sudoassword - tombtmp="$rr"; unset tombtmp -} -# }}} - -function _umountkey { sudo umount $keymount && sudo rmdir $keymount } -function _mountkey { - if [[ -d $keymount ]]; then - _zenwarn "Warning" "Something is already mounted on $keymount. Please check and re-run." - _clean && exit - fi - - sudo mkdir -p $keymount - sudo mount $USBKEY $keymount - - if ! [[ -d $coffindot ]]; then - sudo mkdir $coffindot - fi - -} - -# {{{ zenity dialogs -function _zenques { - zenity \ - --window-icon="$MONMORT" \ - --question \ - --text="$1" -} -function _zenwarn { - zenity \ - --window-icon="$MONMORT" \ - --warning \ - --title="$1" \ - --text="$2" -} -function _zeninfo { - zenity \ - --window-icon="$MONMORT" \ - --info \ - --title="$1" \ - --text="$2" -} -function _zenerr { - zenity \ - --window-icon="$MONMORT" \ - --error \ - --title="$1" \ - --text="$2" -} -function _zenentry { - zenity \ - --window-icon="$MONMORT" \ - --entry \ - --title="$1" \ - --text="$2" \ - --entry-text="$3" -} -# }}} - -function _main { - _clean - cmnd=$(zenity \ - --window-icon="$MONMORT" \ - --title="tombox hook helper" \ - --list \ - --hide-header \ - --text="tombox hook helper\nChoose what hook you want to create:" \ - --separator=" # " \ - --column=Function \ - --column=Description \ - "create" "a new tomb on the tombox" \ - "delete" "a tomb from the tombox" \ - "backup" "a tomb from the tombox" \ - "foobar" "on the tombox") - eval "_$cmnd" -} - -function _create { - vars=$(zenity \ - --window-icon="$MONMORT" \ - --title="Create a new tomb" \ - --forms \ - --text="Enter the info for your new tomb" \ - --separator=":" \ - --add-entry="Tombox username" \ - --add-entry="Tomb name" \ - --add-entry="Tomb's size in MiB") - if [[ $? = 1 ]]; then - exec _main - else - UNDERTAKER=${vars[(ws@:@)1]} - re='^[A-Za-z0-9]+$' - if ! [[ $UNDERTAKER =~ $re ]]; then - _zenwarn "Warning" "Invalid characters in username!" - exec _create - fi - TOMBNAME=${vars[(ws@:@)2]} - if ! [[ $TOMBNAME =~ $re ]]; then - _zenwarn "Warning" "Invalid characters in tomb name!" - exec _create - fi - TOMBSIZE=${vars[(ws@:@)3]} - re='^[0-9]+$' - if ! [[ $TOMBSIZE =~ $re ]]; then - _zenwarn "Warning" "Invalid characters in tomb size!" - exec _create - fi - fi - - feats=$(zenity \ - --window-icon="$MONMORT" \ - --title="Choose features" \ - --text="Choose features you wish to include with your tomb" \ - --list \ - --checklist \ - --separator=":" \ - --column=Yes/No \ - --column=Feature \ - "FALSE" "webdav" \ - "FALSE" "sshfs" \ - "FALSE" "ipfs") - if [[ $? = 1 ]]; then; exec _main; fi - - TOMBHOOKS=$(_zenques "Choose 'Yes' if you want to edit your tomb's bind-hooks and post-hooks") - if [[ $? = 0 ]]; then - bindhook=$(zenity \ - --window-icon="$MONMORT" \ - --title="bind-hooks" \ - --checkbox="Accept these bind-hooks" \ - --text-info \ - --editable) - if [[ $? = 1 ]]; then; exec _main; fi - - posthook=$(zenity \ - --window-icon="$MONMORT" \ - --title="post-hooks" \ - --checkbox="Accept these post-hooks" \ - --text-info \ - --editable) - if [[ $? = 1 ]]; then; exec _main; fi - fi - - USBKEY=$(zenity \ - --window-icon="$MONMORT" \ - --title="Choose USB key" \ - --list \ - --text="Choose your USB key to use" \ - --column="Device path" \ - $(cat ./.devs)) - if [[ $? = 1 ]]; then; exec _main; fi - - _sudo - _mountkey - if [[ -f $hooks ]]; then - _zenques "Warning! There is already an existing hook. Do you want to overwrite?" - if [[ $? = 1 ]]; then - _zeninfo "Info" "Postponing..." && _umountkey && exec _main - else - # edit these to fit new values - print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks - if [[ -n $bindhook ]]; then - print "$bindhook" | sudo tee $coffindot/bindhooks - fi - if [[ -n $posthook ]]; then - print "$posthook" | sudo tee $coffindot/posthooks - fi - _umountkey - _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in a tombox to activate it." - exec _main - fi - else - # edit these to fit new values - print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks - _zeninfo "Success" "$hooks written successfully!\nPlug the USB key in the tombox to activate it." && _umountkey && exec _main - fi - -} - -function _ { rm .devs } -_main