This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
tutorials:keepassgit [2011/05/18 12:14] – clemens | tutorials:keepassgit [2011/05/18 12:49] (current) – 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 " | ||
+ | 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 " |
- | echo " | + | echo " |
- | echo " | + | echo " |
- | touch keepass.kdb.lock | + | touch |
- | keepassx | + | keepassx |
- | rm keepass.kdb.lock | + | rm ${DB_FILE}.lock |
- | exit | + | exit |
- | else | + | |
- | if [ -f keepass.kdb.scriptlock ]; then | + | |
- | echo " | + | |
- | echo " | + | |
- | echo " | + | |
- | exit | + | |
- | else | + | |
- | touch keepass.kdb.scriptlock | + | |
- | git add keepass.kdb.scriptlock | + | |
- | git commit -am " | + | |
- | git push | + | |
- | keepassx keepass.kdb | + | |
- | rm keepass.kdb.scriptlock | + | |
- | git rm keepass.kdb.scriptlock | + | |
- | git commit -am " | + | |
- | git push | + | |
- | fi | + | |
fi | fi | ||
+ | # Check if keepass is already running somewhere else | ||
+ | if [ -f ${DB_FILE}.scriptlock ]; then | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | exit | ||
+ | fi | ||
+ | |||
+ | # Create lock file | ||
+ | touch ${DB_FILE}.scriptlock | ||
+ | git add ${DB_FILE}.scriptlock | ||
+ | git commit -am " | ||
+ | git push | ||
+ | |||
+ | # open Keepass | ||
+ | keepassx ${DB_FILE} | ||
+ | |||
+ | # delete lock file | ||
+ | rm ${DB_FILE}.scriptlock | ||
+ | git rm ${DB_FILE}.scriptlock | ||
+ | git commit -am " | ||
+ | git push | ||
</ | </ | ||