You are not logged in.

#1 2008-07-31 23:57:07

SiB
Member
Registered: 2008-07-03
Posts: 38

Bash script to sync KeepassX database

I created a my first little bash script to sync my Keepass(X) (Keepass on Windows boxes and KeepassX on Linux boxes) over a secure (SSL + Login) webdav enabled site.

#!/bin/bash                                                                                                                                                                                                      
host=https://www.some_dav_enabled_website.com/db.kdb
user=foo
pass=bar
fpath=/somefolder/db.kdb

function update {
    echo "Deleting old KeepassX database..."
    rm $fpath
    echo "Downloading new KeepassX database..."
    curl -sku $user:$pass $host -o $fpath
    echo "Starting KeepassX..."
    keepassx $fpath &
}

function sync {
    echo "Uploading the KeepassX database to server..."
    curl -sku $user:$pass -X PUT -T $fpath $host &> /dev/null
    echo "Database updated!"
}

while getopts "us" optname
  do
    case "$optname" in
      "u")
        update
        ;;
      "s")
        sync
        ;;
      *)
        echo "Usage: -u Update to the latest KeepassX database."
        echo "       -s Sync the (un)modified KeepassX database."
        ;;
    esac
  done

Enjoy ! big_smile

Last edited by SiB (2008-07-31 23:58:59)

Offline

Board footer

Powered by FluxBB