URI: 
       tnew features, unfinished - 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 4397c9fff665abc0674d8b8511267245fad3e817
   DIR parent c7506440481110f3c02d35b7d24518af8aee0a22
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Sun,  6 Mar 2016 01:50:58 +0100
       
       new features, unfinished
       
       Diffstat:
         M makehook.sh                         |      77 ++++++++++++++++++++++++-------
       
       1 file changed, 61 insertions(+), 16 deletions(-)
       ---
   DIR diff --git a/makehook.sh b/makehook.sh
       t@@ -19,7 +19,7 @@ lsblk -npl | awk -F" " '{print $1}' | grep ^/dev/sd.. > ./.devs
        # Hook syntax
        # create:username:tombname:tombsize:passphrase
        
       -# {{{ monmort icon
       +# {{{ icon
        MONMORT="/tmp/monmort.png"
        ICONB64="iVBORw0KGgoAAAANSUhEUgAAACAAAAAgEAQAAACJ4248AAAAAmJLR0T//xSrMc0AAAAJcEhZcwAA\n
        AEgAAABIAEbJaz4AAAAJdnBBZwAAACAAAAAgAIf6nJ0AAADrSURBVFjD5ZZBEsMgCEU/TO/l2XMx\n
       t@@ -31,6 +31,7 @@ WHRkYXRlOmNyZWF0ZQAyMDExLTAxLTEyVDA5OjM0OjI0KzAxOjAwo//d7wAAACV0RVh0ZGF0ZTpt\n
        b2RpZnkAMjAxMS0wMS0xMlQwOTozNDoyNCswMTowMNKiZVMAAAAASUVORK5CYII="
        echo -e "$ICONB64" | base64 --decode > $MONMORT
        # }}}
       +
        # {{{ sudo functions
        function _sudo {
            sudoassword=$(ask_password "Insert sudo password for user $USER")
       t@@ -174,7 +175,6 @@ function _clean {
            while [[ ${#rr} -lt 500 ]]; do
                rr+="$RANDOM"
            done
       -    command="$rr";      unset command
            TOMBPASS="$rr";     unset TOMBPASS
            TOMBSIZE="$rr";      unset TOMBSIZE
            TOMBNAME="$rr";       unset TOMBNAME
       t@@ -242,44 +242,87 @@ function _zenentry {
        
        function _main {
            _clean
       -    command=$(zenity \
       +    cmnd=$(zenity \
                --window-icon="$MONMORT" \
                --title="tombox hook helper" \
                --list \
                --hide-header \
       -        --text="tombox hook helper" \
       -        --separator=" & " \
       +        --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 "_$command"
       +    eval "_$cmnd"
        }
        
        function _create {
       -    UNDERTAKER=$(_zenentry "Choose username" "Choose a username for your tombox" "foobar")    
       -    if [[ $? = 1 ]]; then; exec _main; fi
            
       -    TOMBNAME=$(_zenentry "Choose tomb name" "Choose a name for your new tomb" "foobar")
       -    if [[ $? = 1 ]]; then; exec _main; fi
       +    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
       +       TOMBSIZE=${vars[(ws@:@)3]}
       +        re='^[0-9]+$'
       +        if ! [[ $TOMBSIZE =~ $re ]]; then
       +            _zenwarn "Warning" "Invalid characters in tomb size!"
       +            exec _create
       +        fi
       +        UNDERTAKER=${vars[(ws@:@)1]}
       +        TOMBNAME=${vars[(ws@:@)2]}
       +     fi
        
       -    TOMBPASS=$(_zenentry "Choose password" "Choose a password for your tomb's keyfile" "891y981hy97*HY(*YC&h89h21")
       -    if [[ $? = 1 ]]; then; exec _main; fi
       -    
       -    TOMBSIZE=$(_zenentry "Choose tomb size" "Choose the size of your tomb in MiB" "100")
       +    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="Make bind-hooks" \
       +                   --text="Make your edits for the bind-hooks you wish to include in this tomb" \
       +                   --text-info \
       +                   --editable)
       +        if [[ $? = 1 ]]; then; exec _main; fi
       +
       +        posthook=$(zenity \
       +                   --window-icon="$MONMORT" \
       +                   --title="Make post-hooks" \
       +                   --text="Make your edits for the post-hooks you wish to include in this tomb" \
       +                   --text-info \
       +                   --editable)
       +        if [[ $? = 1 ]]; then; exec _main; fi
       +    fi
        
            USBKEY=$(zenity \
                --window-icon="$MONMORT" \
                --title="Choose USB key" \
                --list \
       -        --hide-header \
                --text="Choose your USB key to use" \
       -        --column=Device \
       +        --column="Device path" \
                $(cat ./.devs))
       +    if [[ $? = 1 ]]; then; exec _main; fi
            
            _sudo
            _mountkey
       t@@ -288,10 +331,12 @@ function _create {
                if [[ $? = 1 ]]; then
                    _zeninfo "Info" "Postponing..." && _umountkey && exec _main
                else
       +            # edit these to fit new values
                    print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks
                    _zeninfo "Success" "$hooks written successfully!" && _umountkey &&  exec _main
                fi
            else 
       +        # edit these to fit new values
                print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${TOMBPASS}" | sudo tee $hooks
                _zeninfo "Success" "$hooks written successfully!" && _umountkey && exec _main
            fi