diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/archlinux-old.sh b/archlinux-old.sh index 4d76328..6513a15 100755 --- a/archlinux-old.sh +++ b/archlinux-old.sh @@ -18,8 +18,8 @@ BASEDIR=/store/mirror/archlinux rsync --verbose --recursive --times --links --hard-links \ --stats --delete-after --ignore-errors \ - ${RSYNCSOURCE} ${BASEDIR} &>> /opt/scripts/archlinux.log || fatal "Failed to rsync from ${RSYNCSOURCE}." + ${RSYNCSOURCE} ${BASEDIR} &>> /var/log/mirror/archlinux.log || fatal "Failed to rsync from ${RSYNCSOURCE}." date &>> /opt/scripts/archlinux.log -echo "############################" &>> /opt/scripts/archlinux.log +echo "############################" &>> /var/log/mirror/archlinux.log diff --git a/archlinux.sh b/archlinux.sh index ef4847c..4aafd41 100755 --- a/archlinux.sh +++ b/archlinux.sh @@ -1,6 +1,6 @@ #!/bin/bash -logfile='/opt/scripts/archlinux.log' +logfile='/var/log/mirror/archlinux.log' fatal() { echo "$1" diff --git a/raspbian.sh b/raspbian.sh new file mode 100755 index 0000000..bcce103 --- /dev/null +++ b/raspbian.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +logfile='/var/log/mirror/raspbian.log' + +fatal() { + echo "$1" + echo -e "Last lines from log:\n" + tail $logfile + exit 1 +} + +home="/store" +target="${home}/mirror/raspbian" +lock='/tmp/raspbiansync.lck' +source='rsync://archive.raspbian.org/archive' + +[ ! -d "${target}" ] && mkdir -p "${target}" + +exec 9>"${lock}" +flock -n 9 || exit + +# only run rsync when there are changes + rsync -rtlvH --safe-links --delete-after --progress -h --timeout=600 --contimeout=60 -p \ + --delay-updates --no-motd \ + ${source} \ + "${target}" &>> $logfile || fatal "Failed to sync." + +date >> $logfile + + diff --git a/ubuntu_archive_two_stage.sh b/ubuntu_archive_two_stage.sh index 15e4129..4b0f051 100755 --- a/ubuntu_archive_two_stage.sh +++ b/ubuntu_archive_two_stage.sh @@ -28,13 +28,13 @@ rsync -4 -q --recursive --times --links --hard-links \ --stats --chmod=a+rx \ --exclude "Packages*" --exclude "Sources*" \ --exclude "Release*" \ - ${RSYNCSOURCE} ${BASEDIR} &>> /opt/scripts/ubuntu_archive_two_stage.log || fatal "First stage of sync failed." + ${RSYNCSOURCE} ${BASEDIR} &>> /var/log/mirror/ubuntu_archive_two_stage.log || fatal "First stage of sync failed." rsync -4 -q --recursive --times --links --hard-links \ --stats --delete --chmod=a+rx --delete-after \ - ${RSYNCSOURCE} ${BASEDIR} &>> /opt/scripts/ubuntu_archive_two_stage.log || fatal "Second stage of sync failed." + ${RSYNCSOURCE} ${BASEDIR} &>> /var/log/mirror/ubuntu_archive_two_stage.log || fatal "Second stage of sync failed." date -u > ${BASEDIR}/project/trace/$(hostname -f) -date &>> /opt/scripts/ubuntu_archive_two_stage.log +date &>> /var/log/mirror/ubuntu_archive_two_stage.log diff --git a/ubuntu_releases.sh b/ubuntu_releases.sh index 450149f..a677bcb 100755 --- a/ubuntu_releases.sh +++ b/ubuntu_releases.sh @@ -26,8 +26,8 @@ fi rsync -q --recursive --times --links --hard-links \ --stats --delete-after \ - ${RSYNCSOURCE} ${BASEDIR} &>> /opt/scripts/ubuntu_releases.log || fatal "Failed to rsync from ${RSYNCSOURCE}." + ${RSYNCSOURCE} ${BASEDIR} &>> /var/log/mirror/ubuntu_releases.log || fatal "Failed to rsync from ${RSYNCSOURCE}." date -u > ${BASEDIR}/.trace/$(hostname -f) -date &>> /opt/scripts/ubuntu_releases.log +date &>> /var/log/mirror/ubuntu_releases.log