# # # add_file "contrib/monotone-mirror-postaction-push.sh" # content [18d31c98caa0513ccdc2c703795e67f081d609e6] # # add_file "examples/push.rc" # content [b9ef14a1cd46dfba882d475a868c11c652c6f399] # # set "contrib/monotone-mirror-postaction-push.sh" # attr "mtn:execute" # value "true" # ============================================================ --- contrib/monotone-mirror-postaction-push.sh 18d31c98caa0513ccdc2c703795e67f081d609e6 +++ contrib/monotone-mirror-postaction-push.sh 18d31c98caa0513ccdc2c703795e67f081d609e6 @@ -0,0 +1,52 @@ +#! /bin/sh +# +# Reads a simple specification in the following form: +# +# SERVER PATTERN ... +# +# and for each line, the given branch PATTERNs are pushed to the given SERVER. +# SERVER has the following syntax: ADDRESS[:PORT] +# +# This script relies on the environment variable DATABASE to point out what +# database to use as source. +# +# $1 specification file name. +# Default: /etc/monotone/push.rc + +if [ -z "$DATABASE" ]; then + echo "No database was given through the DATABASE environment variable" >&2 + exit 1 +fi + +if [ -f "$DATABASE" ]; then :; else + echo "The database $DATABASE doesn't exist" >&2 + echo "You have to initialise it yourself, like this:" >&2 + echo " mtn db init -d $database" >&2 + exit 1 +fi + +rc=$1 +if [ -z "$rc" ]; then + rc=/etc/monotone/push.rc +fi + +if [ -f "$rc" ]; then :; else + echo "The specification file $rc doesn't exist" >&2 + exit 1 +fi + +# Make sure the path to the database is absolute +databasedir=`dirname $DATABASE` +databasefile=`basename $DATABASE` +databasedir=`cd $databasedir; pwd` +database="$databasedir/$databasefile" + +sed -e '/^#/d' < "$rc" | while read SERVER PATTERNS; do + if [ -n "$SERVER" -a -n "$PATTERNS" ]; then + ( eval "set -x; mtn -d \"$database\" push $SERVER $PATTERNS" ) + elif [ -n "$SERVER" -o -n "$PATTERNS" ]; then + echo "SYNTAX ERROR IN LINE '$SERVER $PATTERNS'" + fi +done + +exit 0 ============================================================ --- examples/push.rc b9ef14a1cd46dfba882d475a868c11c652c6f399 +++ examples/push.rc b9ef14a1cd46dfba882d475a868c11c652c6f399 @@ -0,0 +1 @@ +PROJECTBACKUP PROJECTBRANCH*