Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tutorials:keepassgit [2011/05/18 12:14]
clemens
tutorials:keepassgit [2011/05/18 12:49]
clemens
Line 58: Line 58:
 #!/bin/bash #!/bin/bash
  
 +DB_FILE=keepass.kdb
 +
 +# Check if KeePass has already been started
 +if [ -f ${DB_FILE}.lock ]; then
 + echo "​===================================="​
 + echo "​KeePass seems to be already started "
 + echo "​===================================="​
 + exit
 +fi
 +
 +# get latest version from Git server
 git pull origin master git pull origin master
  
 +# Check if pull was unsuccessfull
 if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
-        ​echo "​===================================="​ + echo "​===================================="​ 
-        echo "​Can'​t connect to Git server"​ + echo "​Can'​t connect to Git server"​ 
-        echo "​Keepass db will be READONLY"​ + echo "​Keepass db will be READONLY"​ 
-        echo "​===================================="​ + echo "​===================================="​ 
-        touch keepass.kdb.lock + touch ​${DB_FILE}.lock 
-        keepassx ​keepass.kdb + keepassx ​${DB_FILE} 
-        rm keepass.kdb.lock + rm ${DB_FILE}.lock 
-        exit + exit
-else +
-        if [ -f keepass.kdb.scriptlock ]; then +
-                echo "​========================================="​ +
-                echo "​Keepass is already running somewhere else"​ +
-                echo "​========================================="​ +
-                exit +
-        else +
-                touch keepass.kdb.scriptlock +
-                git add keepass.kdb.scriptlock +
-                git commit -am "​created lock file"​ +
-                git push +
-                keepassx keepass.kdb +
-                rm keepass.kdb.scriptlock +
-                git rm keepass.kdb.scriptlock +
-                git commit -am "​deleted lock file"​ +
-                git push +
-        fi+
 fi fi
 +# Check if keepass is already running somewhere else
 +if [ -f ${DB_FILE}.scriptlock ]; then
 + echo "​=========================================="​
 + echo "​Keepass is already running somewhere else"
 + echo "​=========================================="​
 + exit
 +fi
 +
 +# Create lock file
 +touch ${DB_FILE}.scriptlock
 +git add ${DB_FILE}.scriptlock
 +git commit -am "​created lock file"
 +git push
 +
 +# open Keepass
 +keepassx ${DB_FILE}
 +
 +# delete lock file
 +rm ${DB_FILE}.scriptlock
 +git rm ${DB_FILE}.scriptlock
 +git commit -am "​deleted lock file"
 +git push
 </​code>​ </​code>​