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.

#!/bin/sh
HOSTNAME="rsync://carbslinux.org/repo"
GITDIR="/pub/git/repo"
SHAREDIR="/pub/share/repo"
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"
done

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

[repo]
    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