forked from manjaro/boxit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manjaroreposync
executable file
·36 lines (27 loc) · 973 Bytes
/
manjaroreposync
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
#!/bin/bash
# This script should be a cronjob and should be run a few times a day. (example for /etc/crontab: "0 * * * * root /usr/bin/manjaroreposync").
# However you can also move this script to "/etc/cron.hourly".
# To be an official Manjaro Linux mirror and to get access to our rsync server, you have to tell us your static ip of your synchronization server.
DESTPATH="/path/to/destination"
RSYNC=/usr/bin/rsync
LOCKFILE=/tmp/rsync-manjaro.lock
synchronize() {
$RSYNC -rtlvH --delete-after --delay-updates --safe-links rsync://repo.manjaro.org/repos "$DESTPATH"
}
if [ ! -e "$LOCKFILE" ]
then
echo $$ >"$LOCKFILE"
synchronize
else
PID=$(cat "$LOCKFILE")
if kill -0 "$PID" >&/dev/null
then
echo "Rsync - Synchronization still running"
exit 0
else
echo $$ >"$LOCKFILE"
echo "Warning: previous synchronization appears not to have finished correctly"
synchronize
fi
fi
rm -f "$LOCKFILE"