aboutsummaryrefslogtreecommitdiff
path: root/create-new-projects.sh
blob: f5606798ff9970c4cbb104c92e40c3652641889e (plain)
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
#!/bin/bash
#
# Create/clone new projects from upstreams.
# This script is intended to be run as a cronjob.
#

BASE_DIR=/srv/mirror
MIRROR_DIR=$BASE_DIR/gerrit-mirror

if [ ! -d $MIRROR_DIR ]; then
    mkdir -p $MIRROR_DIR
fi

fatal () {
    echo $1
    exit 1
}

# Require explicit flag to clone new projects, to avoid spurious clones when
# run on a local system to just create new projects. Should be specified
# first if any other options are given.
if [ "$1" == "--clone" ]; then
    clone=1
    shift
fi

./git-gerrit-mirror --mirror-dir=$MIRROR_DIR create $*

if [ -n "$clone" ]; then
    ./git-gerrit-mirror --mirror-dir=$MIRROR_DIR --quiet clone $*
fi