# # # patch "debian/monotone-server.postinst" # from [92d7f6110082768140fcf9ced06a344ee1063170] # to [8bf9b91b187218a6b37d18b10c053fee4aa99ba4] # ============================================================ --- debian/monotone-server.postinst 92d7f6110082768140fcf9ced06a344ee1063170 +++ debian/monotone-server.postinst 8bf9b91b187218a6b37d18b10c053fee4aa99ba4 @@ -56,70 +56,74 @@ fi db_get monotone-server/manage-db - if [ -z "$RET" ]; then - exit 0 - fi + if [ "$RET" = "true" ]; then - # read our passphrase from a file - if [ -e "$MTN_HOME/passphrases" ]; then - db_set monotone-server/passphrase "`cat $MTN_HOME/passphrases | awk '{print $2}'`" - fi + # read our passphrase from a file + if [ -e "$MTN_HOME/passphrases" ]; then + db_set monotone-server/passphrase "`cat $MTN_HOME/passphrases | awk '{print $2}'`" + fi - db_get monotone-server/key - MTN_KEY=$RET + db_get monotone-server/key + MTN_KEY=$RET - db_get monotone-server/passphrase - MTN_KEY_PASSWD=$RET + db_get monotone-server/passphrase + MTN_KEY_PASSWD=$RET - MTN_VERSION="$2" - - # Since we are configuring, we should check if we are upgrading. If we are - # upgrading, we should run the proper db migrate commands if necessary. + MTN_VERSION="$2" + + # Since we are configuring, we should check if we are upgrading. If we are + # upgrading, we should run the proper db migrate commands if necessary. - if [ -z "$2" ]; then - # not upgrading, fresh install + if [ -z "$2" ]; then + # not upgrading, fresh install - # if there is no database, create one - if [ ! -e $MTN_DB ]; then - echo "Creating Monotone database..." >&2 - $MONOTONE --db=$MTN_DB db init \ - --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR - chmod 0600 $MTN_DB - echo "Creating Monotone server keypair..." >&2 + # if there is no database, create one + if [ ! -e $MTN_DB ]; then + echo "Creating Monotone database..." >&2 + $MONOTONE --db=$MTN_DB db init \ + --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR - yes "$MTN_KEY_PASSWD" | - $MONOTONE --db=$MTN_DB genkey $MTN_KEY \ - --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR 2>/dev/null >/dev/null + chmod 0600 $MTN_DB + chown monotone:monotone $MTN_DB - $MONOTONE --db=$MTN_DB pubkey $MTN_KEY \ - --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR > $MTN_HOME/$MTN_KEY.pubkey + echo "Creating Monotone server keypair..." >&2 - echo "Monotone database created successfully." >&2 - fi - elif dpkg --compare-versions "$MTN_VERSION" lt "0.17"; then - # monotone version to old to automatically upgrade - echo "Cannot automatically upgrade from monotone version $2." >&2 - echo -e "Please see UPGRADE and README.changesets in /usr/share/doc/monotone for\n \ - information on upgrading." >&2 - elif dpkg --compare-versions "$MTN_VERSION" lt "0.22"; then - # upgradable version of monotone - echo "Attempting to migrate monotone database..." >&2 - echo "A backup named '`basename $MTN_DB~`' will be created in $MTN_HOME." >&2 + yes "$MTN_KEY_PASSWD" | + $MONOTONE --db=$MTN_DB genkey $MTN_KEY \ + --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR 2>/dev/null >/dev/null + + chown monotone:monotone $MTN_HOME/keys/* - cp $MTN_DB $MTN_DB~ - ($MONOTONE --db=$MTN_DB db migrate \ - --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR >&2 && - echo "Database successfully migrated." >&2) || - (echo "*** Error migrating database. ***" >&2 && + $MONOTONE --db=$MTN_DB pubkey $MTN_KEY --rcfile=$MTN_CONFDIR/hooks.lua\ + --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR > $MTN_HOME/$MTN_KEY.pubkey + + echo "Monotone database created successfully." >&2 + fi + elif dpkg --compare-versions "$MTN_VERSION" lt "0.17"; then + # monotone version to old to automatically upgrade + echo "Cannot automatically upgrade from monotone version $2." >&2 echo -e "Please see UPGRADE and README.changesets in /usr/share/doc/monotone for\n \ - information on manually upgrading your database." >&2) - fi + information on upgrading." >&2 + elif dpkg --compare-versions "$MTN_VERSION" lt "0.22"; then + # upgradable version of monotone + echo "Attempting to migrate monotone database..." >&2 + echo "A backup named '`basename $MTN_DB~`' will be created in $MTN_HOME." >&2 - echo "$MTN_KEY $MTN_KEY_PASSWD" > $MTN_CONFDIR/passphrases - chown monotone:monotone $MTN_CONFDIR/passphrases - chmod 0400 $MTN_CONFDIR/passphrases - db_set monotone-server/passphrase "" + cp $MTN_DB $MTN_DB~ + ($MONOTONE --db=$MTN_DB db migrate --rcfile=$MTN_CONFDIR/hooks.lua\ + --norc --keydir=$MTN_KEYDIR --confdir=$MTN_CONFDIR >&2 && + echo "Database successfully migrated." >&2) || + (echo "*** Error migrating database. ***" >&2 && + echo -e "Please see UPGRADE and README.changesets in /usr/share/doc/monotone for\n \ + information on manually upgrading your database." >&2) + fi + echo "$MTN_KEY $MTN_KEY_PASSWD" > $MTN_CONFDIR/passphrases + chown monotone:monotone $MTN_CONFDIR/passphrases + chmod 0400 $MTN_CONFDIR/passphrases + db_set monotone-server/passphrase "" + fi + ;; abort-upgrade|abort-remove|abort-deconfigure)