summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-03-26 10:33:32 -0300
committerSilvio Rhatto <rhatto@riseup.net>2012-03-26 10:33:32 -0300
commit43f16c99965d8b80b0473fd49768dad44c3bc78c (patch)
tree4b40c7e58f24f499a343712118b70fc289fd34be
parentb988e13c85cf1bce5f025eb08d14199a4658d57c (diff)
downloadkeyringer-43f16c99965d8b80b0473fd49768dad44c3bc78c.tar.gz
keyringer-43f16c99965d8b80b0473fd49768dad44c3bc78c.tar.bz2
Pull and push config changes
-rw-r--r--lib/keyringer/functions41
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 04807e6..2955473 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -226,10 +226,21 @@ function keyringer_set_env {
# Configuration version tracking to help keyring upgrades
function keyringer_check_version {
if [ ! -f "$VERSION_INFO" ]; then
- echo "Creating configuration version file..."
- echo 0 > "$VERSION_INFO"
- if keyringer_is_git "$BASEDIR"; then
- keyringer_exec git "$BASEDIR" add config/version
+ echo "Configuration version file not found, trying to pull from remotes..."
+ for remote in "$BASEDIR/.git/refs/remotes/*"; do
+ keyringer_exec git "$BASEDIR" pull `basename $remote` master
+ done
+
+ if [ ! -f "$VERSION_INFO" ]; then
+ echo "Creating configuration version file..."
+ echo 0 > "$VERSION_INFO"
+ if keyringer_is_git "$BASEDIR"; then
+ keyringer_exec git "$BASEDIR" add config/version
+ echo "Pushing configuration version file to remotes..."
+ for remote in "$BASEDIR/.git/refs/remotes/*"; do
+ keyringer_exec git "$BASEDIR" push $remote master
+ done
+ fi
fi
fi
@@ -237,11 +248,18 @@ function keyringer_check_version {
# Check if config version is supported by keyringer
if [ "$VERSION" != "$KEYRINGER_VERSION" ]; then
- NEWEST="`echo -e "$VERSION\n$KEYRINGER_VERSION" | sort -V | tail -n 1`"
- if [ "$NEWEST" == "$VERSION" ]; then
- echo "Fatal: keyringer version: $KEYRINGER_VERSION / config version: $VERSION"
- echo "Please upgrade your keyringer application"
- exit 1
+ echo "Configuration version differs from keyringer version, trying to pull from remotes"
+ for remote in "$BASEDIR/.git/refs/remotes/*"; do
+ keyringer_exec git "$BASEDIR" pull `basename $remote` master
+ done
+
+ if [ "$VERSION" != "$KEYRINGER_VERSION" ]; then
+ NEWEST="`echo -e "$VERSION\n$KEYRINGER_VERSION" | sort -V | tail -n 1`"
+ if [ "$NEWEST" == "$VERSION" ]; then
+ echo "Fatal: keyringer version: $KEYRINGER_VERSION / config version: $VERSION"
+ echo "Please upgrade your keyringer application"
+ exit 1
+ fi
fi
fi
}
@@ -258,7 +276,10 @@ function keyringer_upgrade {
keyringer_exec git "$BASEDIR" add $RECIPIENTS_BASE/default
keyringer_exec git "$BASEDIR" add config/version
keyringer_exec git "$BASEDIR" commit -m "Config-upgrade-0.1"
- echo "Upgrade to version 0.1 completed"
+ echo "Upgrade to version 0.1 completed, pushing to remotes..."
+ for remote in "$BASEDIR/.git/refs/remotes/*"; do
+ keyringer_exec git "$BASEDIR" push $remote master
+ done
fi
# Update version information