-
Notifications
You must be signed in to change notification settings - Fork 2
/
localup.sh
executable file
·63 lines (52 loc) · 1.41 KB
/
localup.sh
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
#!/bin/bash
LOCALREPO=${LOCALREPO:=/home/arch/local-repo/}
TIER0SERVER=tier0
_remote_path=/srv/http/loongarch/archlinux
if [[ $# -lt 1 ]]; then
echo "Usage: ${0##*/} <repo-name> [option]"
echo "Option:"
echo " --builder Which builder to use(where local-repo is)."
exit 1
fi
BUILDER="localhost"
REPO=$1
while [[ $# -gt 0 ]]; do
case "$1" in
--builder)
shift
BUILDER="$1"
shift
;;
*)
shift
;;
esac
done
WORKDIR=$(mktemp -d)
if [[ "$BUILDER" == "localhost" ]]; then
cp $LOCALREPO/os/loong64/*.zst $WORKDIR || exit 1
else
scp $BUILDER:/$LOCALREPO/os/loong64/*.zst $WORKDIR || exit 1
fi
cd $WORKDIR
ALLFILES=()
for pkg in *.zst; do
if [ ! -f $pkg.sig ]; then
echo "Signing $pkg ..."
gpg --detach-sign $pkg || exit 1
fi
ALLFILES+=($pkg)
done
REMOTE=$(ssh -tt $TIER0SERVER "mktemp -d")
rsync $WORKDIR/* $TIER0SERVER:$REMOTE/ || exit 2
ssh -tt $TIER0SERVER "cd $REMOTE; /home/arch/loongshot/scripts/move-repo.sh $REPO; rmdir $REMOTE"
rm -rf $WORKDIR
echo "Are you sure you want to delete all the files in local-repo?(y/n)"
read -r answer
if [ "$answer" == "y" ]; then
if [[ "$BUILDER" == "localhost" ]]; then
rm $LOCALREPO/os/loong64/*.zst
else
ssh -tt $BUILDER "cd $LOCALREPO/os/loong64; rm *.zst -f; rm local-repo* -f; repo-add local-repo.db.tar.gz"
fi
fi