summaryrefslogtreecommitdiffstats
path: root/bin/reprepro_mirror.sh
blob: b45a978018deb81f699a01659327bdc0e1ee58fe (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
#!/bin/sh

set -e

MODULES="${1:-packages images}"

HOSTNAME="$(hostname -f)"
DOMAIN="$(hostname -d)"

Rsync ()
{
	SERVER="${1}"
	MODULE="${2}"
	DIRECTORY="${3}"

	mkdir -p "${DIRECTORY}"
	touch "${DIRECTORY}/Archive-Update-in-Progress-${HOSTNAME}"

	rsync -aPHv --progress --no-motd \
		${SERVER}::${MODULE} \
		--exclude dists --exclude project/trace \
		"${DIRECTORY}"

	rsync -aPHv --progress --no-motd --delete \
		${SERVER}::${MODULE} \
		"${DIRECTORY}"

	mkdir -p "${DIRECTORY}/project/trace"
	echo "$(date -R)" > "${DIRECTORY}/project/trace/${HOSTNAME}"
}

for MODULE in ${MODULES}
do
	Rsync apt.${DOMAIN} ${MODULE} "/srv/${HOSTNAME}/${MODULE}"
done