blob: 9a3c04b1b75152d7631e1b72f93c0e4df780aa3b (
plain) (
blame)
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
|
#!/bin/sh
# Access git server through podman network if available.
if ping -c 1 cgito &> /dev/null; then
HOST=cgito
else
HOST=git.memzero.de
fi
function mirror() {
local repo=$1
if [ ! -d $repo ]; then
git clone --mirror https://github.com/johannst/$repo
else
git -C $repo fetch --all --prune
fi
git -C $repo push --mirror ssh://$HOST/mirror/$repo
}
function lock() {
# Open lock file.
exec 42<> /tmp/mirror.lock
# Get exclusive lock.
flock -x 42
# Automatically unlock on exit.
trap "flock -u 42" EXIT
}
# Ensure only a single script instance runs at a time.
lock
mkdir -p mirrors
cd mirrors
for R in $(cat /projects.list | awk -F '/' '/mirror/ { print $2 }'); do
echo "==> REPO: $R"
mirror $R
done
|