-
Notifications
You must be signed in to change notification settings - Fork 4
/
rsync-package-arch
executable file
·54 lines (45 loc) · 1.54 KB
/
rsync-package-arch
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
#!/bin/sh
# call rsync to mirror snapshot package for one arch from ftp.hostserver.de
set -eu
if [ $# != 1 ]
then
echo usage: rsync-package-arch arch >&2
exit 2
fi
arch="$1"
host="${host:=217.31.80.35}"
bwlimit="${bwlimit:=2000}"
debug="${debug:=debug}"
rsyncoptions="--partial --delete-excluded --exclude .~tmp~ --exclude '.*'"
rsync="/usr/local/bin/rsync --bwlimit=$bwlimit $rsyncoptions"
tag="rsync-package-arch[$$]"
logger -p daemon.info -t "$tag" "openbsd $arch start"
url="rsync://$host/OpenBSD/snapshots/packages/$arch/"
dir="/data/mirror/openbsd/ftp/snapshots/packages/$arch"
eval $rsync -av "$url" "$dir" | logger -p "daemon.$debug" -t rsync
# extract the signify key version from the base.tgz name
machine="$arch"
[ "$arch" = aarch64 ] && machine=arm64
[ "$arch" = arm ] && machine=armv7
[ "$arch" = mips64 ] && machine=octeon
[ "$arch" = mips64el ] && machine=loongson
[ "$arch" = powerpc ] && machine=macppc
basedir="/data/mirror/openbsd/ftp/snapshots/$machine"
base="`echo "$basedir"/base??.tgz`"
if ! [ -f "$base" ]
then
logger -p daemon.warning -s -t "$tag" "openbsd $basedir no base tgz"
exit 1
fi
version="${base##*/base}"
version="${version%.tgz}"
key="/etc/signify/openbsd-$version-pkg.pub"
logger -p daemon.info -t "$tag" "openbsd $machine signify key $key"
# verify the signature of the new downloaded files
if ! ( cd "$dir" && signify -C -p "$key" -x SHA256.sig )
then
logger -p daemon.warning -t "$tag" "openbsd $dir fail"
else
logger -p daemon.notice -t "$tag" "openbsd $arch success"
fi | logger -p "daemon.$debug" -t signify
exit 0