summaryrefslogtreecommitdiff
path: root/web-server/update-scripts/update-all-gnu-sv-www-repo.sh
blob: 350e9cbf1cb669188aad677c293cb871c324f770 (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
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
#!/bin/sh

# Copyright (C) 2014 Assaf Gordon (assafgordon@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

##
## This script pulls updates for all WWW-GIT repositories,
## regardless of whether they were recently updated or not.
##

die()
{
    BASE=$(basename "$0")
    echo "$BASE: error: $@" >&2
    exit 1
}

log()
{
    DATE=$(date +%F-%H%M%S)
    echo "$DATE: $@" >&2
}

# Directory containing each repository
GITDIR=/var/lib/savannah-checkouts/

for PROJ in $(find "$GITDIR" -maxdepth 1 -type d | sed 1d | sort) ;
do
    cd "$PROJ"

    git fetch --quiet \
        || log "failed to git-fetch in '$PROJ'"

    ## Empty repository? don't try to pull
    git rev-parse HEAD 1>/dev/null 2>&1 \
        || continue

    git pull --quiet \
        || log "failed to git-pull in '$PROJ'"
done

## vim: set shiftwidth=4:
## vim: set tabstop=4:
## vim: set expandtab: