This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:keepassgit [2011/05/18 12:12] – clemens | tutorials:keepassgit [2011/05/18 12:49] (current) – clemens | ||
---|---|---|---|
Line 41: | Line 41: | ||
</ | </ | ||
+ | ==== Usage ==== | ||
+ | |||
+ | * Linux/Unix | ||
+ | * cd ~/keepass | ||
+ | * ./ | ||
+ | * Windows | ||
+ | * Right-Click on the folder that contains the script and database | ||
+ | * Click "Git BASH here" | ||
+ | * ./ | ||
+ | |||
+ | When you start the script, it will try to get the latest version of your keepass db. If there was no successful connection to the server, it will open a read-only version of keepass for you. If the Git pull was successful, the script generates a lock file globally and opens keepass. This prevents that you have opened keepass in write-mode on two or more locations simultanously. When you close keepass, all changes will be commited and pushed to your git server again. | ||
==== The Script ==== | ==== The Script ==== | ||
Line 46: | Line 57: | ||
<code bash> | <code bash> | ||
#!/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 | + | fi |
- | if [ -f keepass.kdb.scriptlock ]; then | + | # Check if keepass is already running somewhere |
- | echo " | + | if [ -f ${DB_FILE}.scriptlock ]; then |
- | echo " | + | echo "==========================================" |
- | echo " | + | echo " |
- | exit | + | echo "==========================================" |
- | else | + | exit |
- | touch keepass.kdb.scriptlock | + | |
- | git add keepass.kdb.scriptlock | + | |
- | git commit -am "lock file erstellt" | + | |
- | git push | + | |
- | keepassx keepass.kdb | + | |
- | rm keepass.kdb.scriptlock | + | |
- | git rm keepass.kdb.scriptlock | + | |
- | git commit -am "lock file geloescht" | + | |
- | git push | + | |
- | fi | + | |
fi | 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 | ||
+ | </ | ||
- | ==== Usage ==== | ||
- | * Linux/Unix | ||
- | * cd ~/keepass | ||
- | * ./ | ||
- | * Windows | ||
- | * Right-Click on the folder that contains the script and database | ||
- | * Click "Git BASH here" | ||
- | * ./ | ||
- | When you start the script, it will try to get the latest version of your keepass db. If there was no successful connection to the server, it will open a read-only version of keepass for you. If the Git pull was successful, the script generates a lock file globally and opens keepass. This prevents that you have opened keepass in write-mode on two or more locations simultanously. When you close keepass, all changes will be commited and pushed to your git server again. |