Up: Rsync Repositories   [Contents][Index]

5.1.1 Setting up an Rsync repository

Carbs Linux repositories automatically sync from the git repostitories and serve it through the rsync daemon. Here is a sample shell script that I use in order to sync repositories. Feel free to customize for your own use.

git -C "$GITDIR" pull

rsync -avcC --delete --include=core --exclude=.rsync,.rsync_root "$GITDIR/." "$SHAREDIR"

printf '%s\n' "$HOSTNAME" > "$GITDIR/.rsync"
for dir in "$GITDIR/"*; do
    [ -d "$dir" ] || continue
    [ -f "$dir/.rsync" ] ||
    printf '%s/%s\n' "$HOSTNAME" "${dir##*/}" > "$dir/.rsync"
    printf '..\n' > "$dir/.rsync_root"

You can then create an rsync user for serving the repositories.

$ adduser -SD rsync

Create ‘/etc/rsyncd.conf’ and a service configuration as well.

uid = rsync
gid = rsync
address = example.com
max connections = 10
use chroot = yes

    path = /pub/share/repo
    comment = My repository

Create a service file at ‘/etc/sv/rsync/run’ (runit):

#!/bin/sh -e
exec rsync --daemon --no-detach