URI: 
       tcli helper script for making 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 8ccca520bb6137c632ce28031296e6a0bcc0389f
   DIR parent 4f1ff06e39b1edb7dc038da5b4609a5d42b36ab2
  HTML Author: parazyd <parazyd@dyne.org>
       Date:   Thu,  7 Apr 2016 14:57:46 +0200
       
       cli helper script for making hooks
       
       Diffstat:
         A helpers/makehook                    |     143 +++++++++++++++++++++++++++++++
       
       1 file changed, 143 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/helpers/makehook b/helpers/makehook
       t@@ -0,0 +1,143 @@
       +#!/usr/bin/env bash
       +#
       +# Helper script to generate hooks for coffin.
       +#
       +# ~ parazyd
       +
       +hooks="hook"
       +davfile="davpasswd"
       +
       +gendav() {
       +        daventry=`echo -n "${undertaker}:WebDAV:" \
       +                && echo -n "${undertaker}:WebDAV:${davpass}" \
       +                | md5sum \
       +                | awk '{print $1}'`
       +}
       +
       +successmsg() {
       +        cat <<EOF
       +
       +Your hook has been created successfully. Plug your USB key into the coffin to
       +execute it, or rerun this script to create another hook.
       +
       +EOF
       +}
       +
       +genhook() {
       +        case $1 in
       +                create)
       +                        hookentry="create:${undertaker}:${tombname}:${tombsize}:webdav"
       +                        echo $hookentry >> $hooks
       +                        gendav
       +                        echo $daventry >> $davfile
       +                        ;;
       +                delete)
       +                        echo "delete"
       +                        ;;
       +                backup)
       +                        echo "backup"
       +                        ;;
       +                *)
       +                        echo "fuck off"
       +                        ;;
       +        esac
       +}
       +
       +happenz() {
       +        case $1 in
       +                1)
       +                        echo -e "\n"
       +                        echo "Creating a new tomb..."
       +
       +                        read -p "Please input the username you wish to use: " undertaker
       +                        re='^[A-Za-z0-9]+$'
       +                        [[ $undertaker =~ $re ]] || {
       +                                echo "ERROR: Invalid characters in username."
       +                                exec $0
       +                        }
       +
       +                        read -p "Please input the name you wish to use for your tomb: " tombname
       +                        [[ $tombname =~ $re ]] || {
       +                                echo "ERROR: Invalid characters in tomb name."
       +                                exec $0
       +                        }
       +
       +                        read -p "Please input the size of your tomb in MiB: " tombsize
       +                        re='^[0-9]+$'
       +                        [[ $tombsize =~ $re ]] || {
       +                                echo "ERROR: Invalid characters in tomb size."
       +                                exec $0
       +                        }
       +
       +                        read -r -p "Please input the password you will use to access your tomb: " davpass
       +
       +                        genhook create
       +                        [[ $? = 0 ]] && {
       +                                successmsg        
       +                        }
       +                        ;;
       +                2)
       +                        echo -e "\n"
       +                        echo "Deleting an exising tomb..."
       +
       +                        read -p "Please input the username you used to create the tomb: " undertaker
       +                        re='^[A-Za-z0-9]+$'
       +                        [[ $undertaker =~ $re ]] || {
       +                                echo "ERROR: Invalid characters in username."
       +                                exec $0
       +                        }
       +
       +                        read -p "Please input the name you used for your tomb: " tombname
       +                        [[ $tombname =~ $re ]] || {
       +                                echo "ERROR: Invalid characters in tomb name."
       +                                exec $0
       +                        }
       +
       +                        # NOTE: possibly include prompt for webdav password
       +
       +                        genhook delete
       +                        [[ $? = 0 ]] && {
       +                                successmsg
       +                        }
       +
       +                        ;;
       +                3)
       +                        echo -e "\n"
       +                        echo "backin up"
       +                        ;;
       +                4)
       +                        echo -e "\n"
       +                        echo "Toggling state..."
       +                        ;;
       +                *)
       +                        echo -e "\n"
       +                        echo "No valid option. Exiting..."
       +                        return 1
       +                        exit
       +                        ;;
       +        esac
       +}
       +
       +main() {
       +        cat <<EOF
       +
       +#########################################################
       +                   ..:: COFFIN ::..
       +   = cryptographic office filer for important nuggets =
       +                      version 0.4
       +               https://coffin.dyne.org
       +
       +1) Create a new tomb on the coffin
       +2) Delete an existing tomb on the coffin
       +3) Backup a tomb from the coffin
       +4) Toggle your tomb's open/close state
       +
       +#########################################################
       +
       +EOF
       +
       +read -n 1 -p "Type in the number of the function you wish to perform: " action
       +happenz $action
       +}
       +
       +main