-
Notifications
You must be signed in to change notification settings - Fork 1
/
rpmfusion-free_mirror.sh
executable file
·50 lines (46 loc) · 1.97 KB
/
rpmfusion-free_mirror.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
#!/bin/sh
# fedora-nonfree_mirror.sh
# set VARS
DATE=`date \`\`+%a_%b_%d_%y_%H_%M''`
DATENICE=`date \`\`+%a\ -\ %b\ %d,\ %Y\ -\ %H:%M''`
YEST_DATE=`date -d yesterday \`\`+%a_%b_%d_%y''`
EMAIL="[email protected]"
P_DIR=/limbus/centos/status #P is for PATCH - ; )
R_DIR=/limbus/centos/fedora/rpmfusion/free
P_DATEFILE=RPMFUSION-FREE.LAST_UPDATE
P_LOG=$P_DIR/RPMFUSION-FREE_LAST_MIRRORED.$DATE
O_LOG=$P_DIR/RPMFUSION-FREE_LAST_MIRRORED.$YEST_DATE #O is for OLD
T_LOG=$P_DIR/RPMFUSION-FREE_MIRROR_IN_PROGRESS.$DATE
E_LOG=$P_DIR/RPMFUSION-FREE_BROKE_ON.$DATE #E is for ERROR
RSYNC_COMMAND=/usr/local/share/rutgers-mirror-scripts/run-mirror-rpmfusion-free.sh
cd $P_DIR
# use rsync to get the patches. execute command in $RSYNC_COMMAND
# and writes to $T_LOG
$RSYNC_COMMAND > $T_LOG 2>&1
exitcode=$?
if [ "$exitcode" -eq 0 ] # exit status OK
then
echo $DATENICE > $P_DIR/$P_DATEFILE
REPODATA_DIR=$(ls -td $(find $R_DIR -maxdepth 5 -name repodata -type d) |awk "NR==1")
REPODATA_DIR_DATE=`date -r $REPODATA_DIR \`\`+%a\ -\ %b\ %d,\ %Y\ -\ %H:%M''`
echo $REPODATA_DIR_DATE >> $P_DIR/$P_DATEFILE
mv $T_LOG $P_LOG
logger -p cron.notice -t $0 `tail -n 2 $P_LOG` # log it
tail -n 30 $P_LOG > $P_LOG.short
rm -f $P_LOG.short
rm -f $O_LOG* # remove previous days log
chmod -R 755 $P_DIR
chown -R root:root $P_DIR
else
mv $T_LOG $E_LOG
tail -n 30 $E_LOG > $E_LOG.short
rm -f $E_LOG.short
logger -p cron.err -t $0 `tail -n 5 $E_LOG` # write to syslog on failure
chmod -R 755 $P_DIR
chown -R root:root $P_DIR
OUTOFDATE=`find /limbus/centos/status -mtime -1 -name 'FEDORA-NONFREE_LAST_MIRROR*' | wc -l`
if [ "$OUTOFDATE" -eq 0 ]
then
echo "Warning: RPMFUSION-FREE mirror out of date by 24 hours, please check logs at http://centos.rutgers.edu/mirror/status " | mail -s "RPMFUSION-FREE MIRROR 24 Hours out of date" $EMAIL
fi
fi