This file is indexed.

/usr/share/doc/monotone/contrib/monotone-mirror.sh is in monotone 1.0-12.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/sh
#
# Reads a simple specification with lines describing what to do.
# The lines may be several of the following:
#
#	key		KEYDIR KEYID
#
#	mirror		SERVER	[OPTIONS ...] PATTERN ...
#
#	postaction	COMMAND
#
# All "mirror" lines describe what to pull from what servers.  Everything
# ends up in one database.
#
# All "postaction" lines describe a command to be evaluated after mirroring
# is done.  When each command is evaluated, the environment variable DATABASE
# contains the name of the database for them to use.
#
# All "mirror" lines are executed first, then all "postaction" lines.
# "key" lines are always executed in place, and affect any subsequent "mirror"
# or "postaction" line.
#
# $1	database to use.  Must be initialised beforehand or this will fail!
#	Default: /var/lib/monotone/mirror/mirror.mtn
# $2	specification file name.
#	Default: /etc/monotone/mirror.rc

set -e

database=$1
if [ -z "$database" ]; then
    database=/var/lib/monotone/mirror/mirror.mtn
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=$2
if [ -z "$rc" ]; then
    rc=/etc/monotone/mirror.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"

mkdir -p $database.redo
mkdir $database.lock1 || \
    (echo 'Database locked by another process'; exit 1) && \
    (
    touch $database.keyvars
    while [ -d $database.redo ]; do
	rmdir $database.redo
	sed -e '/^#/d' < "$rc" | while read KEYWORD ARGS; do
	    case $KEYWORD in
		key)
		    set $ARGS
		    keydir=$1
		    keyid=$2
		    keydiropt=""
		    keyidopt=""
		    if [ -n "$keydir" ]; then keydiropt="--keydir='$keydir'"; fi
		    if [ -n "$keyid" ]; then keyidopt="--key='$keyid'"; fi
		    (
			echo "keydiropt=\"$keydiropt\""
			echo "keyidopt=\"$keyidopt\""
		    ) > $database.keyvars
		    ;;
		mirror)
		    echo "$ARGS" | while read SERVER PATTERNS; do
			if [ -z "$SERVER" -o -z "$PATTERNS" ]; then
			    echo "Server or pattern missing in line: $SERVER $PATTERNS" >&2
			    echo "Skipping..." >&2
			else
			    ( 
				. $database.keyvars
				eval "set -x; mtn -d '$database' '$keydiropt' '$keyidopt' --ticker=dot pull $SERVER $PATTERNS"
			    )
			fi
		    done
	    esac
	done

	sed -e '/^#/d' < "$rc" | while read KEYWORD ARGS; do
	    case $KEYWORD in
		key)
		    set $ARGS
		    keydir=$1
		    keyid=$2
		    keydiropt=""
		    keyidopt=""
		    if [ -n "$keydir" ]; then keydiropt="--keydir='$keydir'"; fi
		    if [ -n "$keyid" ]; then keyidopt="--key='$keyid'"; fi
		    (
			echo "keydiropt=\"$keydiropt\""
			echo "keyidopt=\"$keyidopt\""
		    ) > $database.keyvars
		    ;;
		postaction)
		    if [ -z "$ARGS" ]; then
			echo "Command missing in line: $ARGS" >&2
			echo "Skipping..." >&2
		    else
			(
			    . $database.keyvars
			    DATABASE="$database" \
				KEYDIROPT="$keydiropt" KEYIDOPT="$keyidopt" \
				eval "set -x; $ARGS"
			)
		    fi
	    esac
	done
    done

    rmdir $database.lock1
    rm $database.keyvars
    )