"Fossies" - the Fresh Open Source Software Archive

Member "dbtool-1.9.1/samples/account-db/accdb" (15 May 2015, 2100 Bytes) of package /linux/privat/dbtool-1.9.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "accdb": 1.9_vs_1.9.1.

    1 #!/bin/sh
    2 #
    3 # This is a little interactive tool which helps you
    4 # to maintain your accounts on one place.
    5 #
    6 # It uses an encrypted database for protecting the
    7 # account list. The tool does not work with temporary
    8 # files for security reasons.
    9 #
   10 # Just execute it. It will show you a little menu of
   11 # all available commands. That's really easy :-)
   12 #
   13 # T.v. Dein <tlinden@cpan.org>
   14 
   15 
   16 #
   17 # the account database
   18 db=~/.accdb
   19 
   20 #
   21 # check if dbtool version is 1.4 or higher
   22 version=`dbtool -V 2>&1 | sed 's/[a-zA-Z .]*//g'`
   23 if test -n "$version"; then
   24     if test $version -lt 14; then
   25     echo "This version of dbtool does not support encryption!"
   26     exit 1
   27     fi
   28 else
   29     echo "dbtool is not installed!"
   30     exit 1
   31 fi
   32 
   33 #
   34 # get the passphrase
   35 echo -n "Enter passphrase: "
   36 read PW
   37 
   38 if test -z "$PW"; then
   39     echo "empty passphrase!"
   40     exit -1
   41 fi
   42 
   43 #
   44 # store it in a local environment variable,
   45 # so it will not appear in the process list and
   46 # dbtool itself will not ask for it
   47 export DB_PASSPHRASE=$PW
   48 
   49 
   50 #
   51 # the silly menu
   52 function menu {
   53     echo
   54     echo -n "[L]ist [N]ew [S]earch [Q]uit> "
   55 }
   56 
   57 
   58 #
   59 # go
   60 echo
   61 menu
   62 
   63 while :
   64 do
   65     read command
   66 
   67     case $command in
   68       l|L)
   69     echo
   70     if [ -e $db ]; then
   71         #
   72         # just dump all entries out. Use a custom output
   73         # separator for better formatting with sed :-)
   74         dbtool -d $db -p -D -F "" | sed 's//  =>   /'
   75     fi
   76       n|N)
   77     echo
   78     echo -n "Enter entry name: "
   79     read name
   80     if [ "x$name" = "x" ]; then
   81         echo "empty name!"
   82     else
   83         echo -n "Enter username: "
   84         read user
   85         echo -n "Enter password: "
   86         read pass
   87         #
   88         # create a new entry, separate the key and the value
   89         # using the pipe character, overwrite existing entry
   90         echo "$name| Username: $user, Password: $pass" \
   91         | dbtool -p -i -f -d $db -F "|"
   92         echo "entry $name inserted."
   93     fi
   94       s|S)
   95     echo -n "Enter search string: "
   96     read string
   97     #
   98     # search for the given key
   99     dbtool -p -d $db -s -k $string
  100       q|Q)
  101     echo
  102     echo "Thanks for the fish."
  103     echo
  104     exit 0
  105     esac
  106 
  107     menu
  108 done
  109 
  110 #
  111 # clear the environment variable. just in case...
  112 unset DB_PASSPHRASE