Local repo mirror: различия между версиями

Материал из Webko Wiki
Перейти к навигации Перейти к поиску
(Новая страница: «Категория:ArchLinux == Синхронизация с основными репами == <syntaxhighlight lang="bash"> crontab -l /usr/local/sbin/sy…»)
 
(нет различий)

Текущая версия на 17:25, 26 апреля 2017


Синхронизация с основными репами

crontab -l
/usr/local/sbin/sync_archlinux.sh
#!/bin/bash

#################################################################################################
### It is generally frowned upon to create a local mirror due the bandwidth that is required.
### One of the alternatives will likely fulfill your needs.
### REMEMBER:
###   * Bandwidth is not free for the mirrors. They must pay for all the data they serve you
###       => This still applies although you pay your ISP 
###       => There are many packages that will be downloaded that you will likely never use
###       => Mirror operators will much prefer you to download only the packages you need
###   * Really please look at the alternatives on this page:
###       https://wiki.archlinux.org/index.php?title=Local_Mirror
### If you are ABSOLUTELY CERTAIN that a local mirror is the only sensible solution, then this
### script will get you on your way to creating it. 
#################################################################################################

# Configuration
SOURCE='rsync://mirror.23media.de/archlinux/'
#SOURCE='rsync://archlinux.bln-ua.net/archlinux/'
DEST='/srv/mirror/archlinux'
BW_LIMIT='500'
REPOS='core extra community multilib iso community-staging community-testing gnome-unstable kde-unstable multilib-staging multilib-testing multilib pool staging testing lastsync lastupdate'
RSYNC_OPTS="-rtlH --delete-after --delay-updates --safe-links --max-delete=1000"
LCK_FLE='/var/run/mirror/repo-sync.lck'

PATH='/usr/bin'

# Make sure only 1 instance runs
if [ -e "$LCK_FLE" ] ; then
        OTHER_PID=$(cat $LCK_FLE)
        echo "Another instance already running: $OTHER_PID"
        exit 1
fi
echo $$ > "$LCK_FLE"

for REPO in $REPOS ; do
        echo "Syncing $REPO"
        rsync $RSYNC_OPTS ${SOURCE}/${REPO} ${DEST}
done

# Cleanup
rm -f "$LCK_FLE"

exit 0

Сервер rsync

cat /etc/xinetd.d/rsync

service rsync
{
        disable                 = no
        socket_type             = stream
        port                    = 873
        protocol                = tcp
        wait                    = no
        user                    = root
        server                  = /usr/bin/rsync
        server_args             = --daemon
        log_on_success  += HOST DURATION
        log_on_failure  += HOST
}