summaryrefslogtreecommitdiff
path: root/parabola-repos-speed-test
blob: ad790b170b4df9a8c55568b521937baac3795a38 (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
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
129
130
131
132
133
134
135
136
#!/bin/bash

# alfplayer
# 2014-06-12
#
# Test Parabola HTTP(S) and rsync mirror speeds.

mail_to="your@mail.com"

script_filename="$(basename "$0")"

log_dir="$HOME/log/${script_filename}"

if [[ ! -d ${log_dir} ]] ; then
    mkdir "${log_dir}"
fi

if [[ ! -w ${log_dir} ]] ; then
	echo -e "Can't write to log file directory: \"${log_dir}\".
Nothing done."
	exit 1
fi

echo "=> ${script_filename} started. Start time: $(date -u --rfc-3339=seconds)" >> "${log_dir}/${script_filename}"

# Locking and send email on exit
exit_trap() {
    if [[ ${mail_to} ]] ; then
        echo "=> Sending output to ${mail_to}"
        mail -s "[$(hostname)] ${script_filename}" "${mail_to}" < <(tail -n 1 /var/log/"${script_filename}"/*)
        rm -rf "$lockdir"
    fi
}

lockdir="/tmp/${script_filename}.lock"

if mkdir "$lockdir" ; then
    # Remove lockdir when the script finishes, or when it receives a signal
    trap exit_trap 0    # remove directory when script finishes

    # Optionally create temporary files in this directory, because
    # they will be removed automatically:
    tmpfile="$lockdir/filelist"
else
    echo >&2 "cannot acquire lock, giving up on $lockdir"
    exit 0
fi

test() {
        echo -n "$(date -u --rfc-3339=seconds)   " >> "${log_dir}/$repo"
        filename="$(wget --no-check-certificate -q ${url}/community/os/x86_64/community.db -O - | tar xzO | grep '^vtk-.*pkg.tar.*$')"
        wget --no-check-certificate -O /dev/null ${url}/community/os/x86_64/"${filename}" 2>&1 | sed -n -e 's|^.*(\([0-9.]\+ [KM]B/s\)).*$|\1|p' >> "${log_dir}/$repo"
}

# parabolagnulinux.mirrors.linux.ro
repo=parabolagnulinux.mirrors.linux.ro
url='http://parabolagnulinux.mirrors.linux.ro'
test

# repo.parabola.nu
repo=repo.parabola.nu
url='http://repo.parabola.nu'
test

# alfplayer.com
repo=alfplayer.com
url='http://alfplayer.com/parabola'
test

# snapshots.alfplayer.com
repo=snapshots.alfplayer.com
url='http://snapshots.alfplayer.com/parabola'
test

# yandex.ru
repo=yandex
url='http://mirror.yandex.ru/mirrors/parabola'
test

# https://parabola.goodgnus.com.ar/
repo=goodgnus
url='https://parabola.goodgnus.com.ar'
test

# b.mirrors.fryxell.info
# !! HTTP instead of HTTPS as listed in the file "mirrorlist"
repo=b.mirrors.fryxell.info
#url='https://parabola.fryxell.info'
url='http://b.mirrors.fryxell.info/parabolagnulinux'
test

# custom file
#repo=""
#url=""
#echo -n "$(date -u --rfc-3339=seconds)   " >> "${log_dir}/$repo"
#wget --no-check-certificate -O /dev/null "$url" 2>&1 | sed -n -e 's|^.*(\([0-9.]\+ [KM]B/s\)).*$|\1|p' >> "${log_dir}/$repo"


echo "Rsync test"
echo "Using amsn package (around 11 MB)"

test_rsync() {
    echo -n "$(date -u --rfc-3339=seconds)   " >> "${log_dir}/$repo"
    rm -f /tmp/"${script_filename}"-test.db
    rsync -L --no-motd ${SERVER}/community/os/x86_64/community.db /tmp/"${script_filename}"-test.db
    filename="$(tar xzOf /tmp/${script_filename}-test.db | grep '^amsn-.*pkg.tar.*$')"
    rsync -Lv --no-motd ${SERVER}/community/os/x86_64/"${filename}" /tmp/"${script_filename}"-testfile | \
	grep -o '[0-9,.]* bytes/sec' >> "${log_dir}/$repo"
    rm -f /tmp/"${script_filename}"-testfile
}

repo=rsync_alfplayer.com
SERVER="rsync://alfplayer.com:873/repos/parabola"
test_rsync

repo=rsync_snapshots_alfplayer
SERVER="rsync://snapshots.alfplayer.com/repos/parabola"
test_rsync

repo=rsync_parabolagnulinux.mirrors.linux.ro
SERVER="rsync://parabolagnulinux.mirrors.linux.ro/parabolagnulinux"
test_rsync

repo=rsync_repo.parabola.nu
SERVER="rsync://repo.parabola.nu:875/repos"
test_rsync

repo=rsync_yandex
SERVER="rsync://mirror.yandex.ru/mirrors/parabola"
test_rsync

repo=rsync_archlinux_unicamp
SERVER="rsync://rsync.las.ic.unicamp.br/pub/archlinux"
test_rsync

echo "=> ${script_filename} finished successfully. Finish time: $(date -u --rfc-3339=seconds)" >> "${log_dir}/${script_filename}"