init; not very clean

This commit is contained in:
Dict Xiong 2022-11-20 12:02:29 +08:00
commit 0690b9552b
4 changed files with 25 additions and 0 deletions

3
locked.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/zsh
sed -i '4 s/$/?/' /mnt/mirrors/status/${1//\//\-}.log

3
postsync.sh Executable file
View File

@ -0,0 +1,3 @@
#! /bin/zsh
echo -e "${1}\n$(du -h --max-depth=0 /mnt/mirrors/$1 | awk '{print $1}')\n$(date +'%Y-%m-%d %H:%M:%S')\n${2}" > /mnt/mirrors/status/${1//\//\-}.log

4
presync.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/zsh
sed -i "4c syncing..." /mnt/mirrors/status/${1//\//\-}.log
sed -i "3c $(date +'%Y-%m-%d %H:%M:%S')" /mnt/mirrors/status/${1//\//\-}.log

15
sync.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/zsh
for src in {CTAN,ubuntu,docker-ce/linux/ubuntu,ubuntu-releases}
do
if [ ! -f "/tmp/mirror-${src//\//\-}.lock" ];
then
touch /tmp/mirror-${src//\//\-}.lock
/home/root/programs/dxsync/presync.sh $src
rsync -4avzthP --stats --delete --bwlimit=6000 --log-file=/var/log/rsync-mirrors-${src//\//\-}.log rsync://mirrors4.tuna.tsinghua.edu.cn/$src /mnt/mirrors/$src
/home/root/programs/dxsync/postsync.sh ${src} $?
rm /tmp/mirror-${src//\//\-}.lock
else
/home/root/programs/dxsync/locked.sh $src
fi
done