aboutsummaryrefslogtreecommitdiff
path: root/fetch-logs.sh
blob: 7fc75abb34b741c7cba9850e70af9f8b05ae1695 (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
57
58
59
60
61
62
63
64
65
#!/bin/sh

USER=logaccess
OWNER=weblogs:linaro
KEY=/home/weblogs/.ssh/id_logaccess_rsa
LOGS_DIR=/home/weblogs/logs

[ -z "$DEBUG" ] && DEBUG=1
if [ $DEBUG -eq 0 ]; then
    RSYNC_OPT="-aq"
else
    RSYNC_OPT="-av"
fi

debug_out ()
{
    if [ "$DEBUG" -eq 1 ]; then
        echo "$@"
        "$@"
    else
        "$@"
        if [ $? -ne 0 ]; then
            echo "Error was in command:"
            echo "$@"
            echo
        fi
    fi
}

fetch ()
{
    ssh_host=$1
    service=$2
    filter=$3
    if [ -z "$service" ]; then
        service=$ssh_host
    fi
    mkdir -p $LOGS_DIR/$service
    debug_out /usr/bin/rsync $RSYNC_OPT -e "ssh -i $KEY" $USER@$ssh_host:/var/log/apache2/ \
        --rsync-path="sudo rsync" --include="${filter}access*.gz" --exclude="*" \
        $LOGS_DIR/$service/.
}

gitolite_fetch ()
{
    ssh_host=$1
    service=$2
    mkdir -p $LOGS_DIR/$service
    debug_out /usr/bin/rsync $RSYNC_OPT -e "ssh -i $KEY" $USER@$ssh_host:/home/git/.gitolite/logs/ \
        --rsync-path="sudo rsync" $LOGS_DIR/$service/.
}

fetch www-admin.linaro.org www.linaro.org
fetch releases.linaro.org releases.linaro.org 'releases*'
fetch snapshots.linaro.org snapshots.linaro.org 'snapshots*'
fetch cards.linaro.org
fetch collaborate.linaro.org
fetch performance.linaro.org
fetch builds.96boards.org builds.96boards.org 'builds*'
fetch git-us.linaro.org git-us.linaro.org 'git.linaro.org-'
fetch git-ie.linaro.org git-ie.linaro.org 'git.linaro.org-'
fetch git-ap.linaro.org git-ap.linaro.org 'git.linaro.org-'

gitolite_fetch git-us.linaro.org git-us.linaro.org
#chown -R $OWNER $LOGS_DIR