twebdav implementation - coffin - secure lan file storage on a device
 (HTM) git clone git://parazyd.org/coffin.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 490b71a2cd862f90538d3cf1ea5b26d6124881c4
 (DIR) parent 6220dc5a83eeff6355d94ce2b4243b8d932cd83c
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Mon,  7 Mar 2016 20:52:08 +0100
       
       webdav implementation
       
       Diffstat:
         M bin/sacrist                         |      17 ++++++++++++++++-
         M gmakehook                           |      41 +++++++++++++++++++++++++++++++
       
       2 files changed, 57 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/bin/sacrist b/bin/sacrist
       t@@ -110,6 +110,7 @@ _ttabmagic() {
                    sudo -u $undertaker $tomb open $graveyard/$tombid.tomb -k $coffindot/$tombid.key \
                        --unsafe --tomb-pwd "$keypass"
        
       +            chmod g+rw /media/$tombid
                    if [[ -d "/media/$tombid" ]]; then
                        print "$undertaker:$keyhash:$keyuuid" >> $tombs && chmod 600 $tombs && _msg info "Added info to $tombs" 
                    else
       t@@ -142,6 +143,20 @@ _create_new_tomb() {
                _msg warn "User $undertaker exists. Continuing..."
            fi
        
       +    if [[ $entry =~ webdav && -f $coffindot/webdav.conf ]]; then
       +        _msg info "Found WebDAV data. Setting up..."
       +        cat $coffindot/davinfo >> /etc/apache2/davpasswd
       +        _msg info "Wrote to davpasswd"
       +        sed -i -e :a -e '$d;N;2,3ba' -e 'P;D' /etc/apache2/sites-available/tomboxdav.conf
       +        cat webdav.conf >> /etc/apache2/sites-available/tomboxdav.conf
       +        _msg info "Wrote to tomboxdav.conf"
       +        gpasswd -a www-data $undertaker
       +        /etc/init.d/apache2 restart
       +        _msg info "Done setting up WebDAV!"
       +    else
       +        _msg info "No WebDAV data found. Continuing..."
       +    fi
       +
            sudo -u $undertaker $tomb dig -s $tombsize $graveyard/$tombid.tomb    
            sudo -u $undertaker $tomb forge $graveyard/$tombid.key --unsafe --tomb-pwd "$keypass"
            sudo -u $undertaker $tomb lock $graveyard/$tombid.tomb -k $graveyard/$tombid.key \
       t@@ -149,7 +164,7 @@ _create_new_tomb() {
        
            mv $graveyard/$tombid.key $coffindot/ && chown $undertaker:$undertaker $coffindot/$tombid.key && \
                _msg info "Moved and chowned keyfile"
       -    print "$undertaker:${tombid}:true" >> $ttab 
       +    print "${undertaker}:${tombid}:true" >> $ttab 
            keyhash=$(_hashkey)
            print "${keyhash}:${keypass}" >> $tombpasswd
            _msg info "Wrote to $ttab and $tombpasswd"
 (DIR) diff --git a/gmakehook b/gmakehook
       t@@ -230,6 +230,35 @@ function _mountkey {
            fi
        }
        
       +# {{{ _writedavinfo
       +function _writedavinfo {
       +    if [[ -n $davpass ]]; then
       +        davinfo=$(echo -n "$UNDERTAKER:WebDAV:" \
       +                && echo -n "$UNDERTAKER:WebDAV:$davpass" \
       +                | md5sum \
       +                | awk '{print $1}')
       +        print $davinfo > $coffindot/davinfo
       +    fi
       +
       +    cat <<EOF > $coffindot/webdav.conf
       +
       +    alias /${TOMBNAME} /media/${TOMBNAME}
       +    <Directory "/media/${TOMBNAME}">
       +        Dav On
       +        AllowOverride none
       +        Options Indexes FollowSymlinks
       +        AuthType Digest
       +        AuthName WebDAV
       +        AuthUserFile /etc/apache2/davpasswd
       +        Require user ${UNDERTAKER}
       +    </Directory>
       +
       +    </VirtualHost>
       +</IfModule>
       +EOF
       +}
       +# }}}
       +
        function _main {
            _clean
            cmnd=$(zenity \
       t@@ -295,6 +324,16 @@ function _create {
                "FALSE" "ipfs")
            if [[ $? = 1 ]]; then; exec _main; fi
        
       +    if [[ $feats =~ "webdav" ]]; then
       +        _zenques "Do you already have a WebDAV login?"
       +        if [[ $? = 1 ]]; then
       +            davpass=$(_zenentry "WebDAV Password" \
       +                "Insert the password you want to use for WebDAV login:" \
       +                "my very strong password")
       +            if [[ $? = 1 ]]; then; davpass=""; fi
       +        fi
       +    fi
       +
            TOMBHOOKS=$(_zenques "Choose 'Yes' if you want to edit your tomb's bind-hooks and post-hooks")
            if [[ $? = 0 ]]; then
                bindhook=$(zenity \
       t@@ -336,6 +375,7 @@ function _create {
                    _zeninfo "gmakehook" "Postponing..." && _umountkey && exec _main
                else
                    print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks
       +            if [[ $feats =~ "webdav" ]]; then; _writedavinfo; fi
                    if [[ -n $bindhook ]]; then
                        print "$bindhook" | sudo tee $coffindot/bindhooks
                    fi
       t@@ -347,6 +387,7 @@ function _create {
                fi
            else 
                print "create:${UNDERTAKER}:${TOMBNAME}:${TOMBSIZE}:${feats}" | sudo tee $hooks
       +        if [[ $feats =~ "webdav" ]]; then; _writedavinfo; fi
                if [[ -n $bindhook ]]; then
                    print "$bindhook" | sudo tee $coffindot/bindhooks
                fi