summaryrefslogtreecommitdiff
path: root/rsync
diff options
context:
space:
mode:
authorJohannes Winkelmann <jw@smts.ch>2006-02-23 15:26:10 +0000
committerJohannes Winkelmann <jw@smts.ch>2006-02-23 15:26:10 +0000
commite3afe2298e821d7f5860128720e665d8fb3bd641 (patch)
treebfb499432688352b1140b13ad8252c8e4e739006 /rsync
downloadcore-e3afe2298e821d7f5860128720e665d8fb3bd641.tar.gz
core-e3afe2298e821d7f5860128720e665d8fb3bd641.tar.xz
create branch for 2.2
Diffstat (limited to 'rsync')
-rw-r--r--rsync/.footprint18
-rw-r--r--rsync/.md5sum4
-rw-r--r--rsync/Pkgfile23
-rw-r--r--rsync/rsync.driver142
-rw-r--r--rsync/rsyncd23
-rw-r--r--rsync/rsyncd.conf15
6 files changed, 225 insertions, 0 deletions
diff --git a/rsync/.footprint b/rsync/.footprint
new file mode 100644
index 00000000..dbb4683a
--- /dev/null
+++ b/rsync/.footprint
@@ -0,0 +1,18 @@
+drwxr-xr-x root/root etc/
+drwxr-xr-x root/root etc/ports/
+drwxr-xr-x root/root etc/ports/drivers/
+-rwxr-xr-x root/root etc/ports/drivers/rsync
+drwxr-xr-x root/root etc/rc.d/
+-rwxr-xr-x root/root etc/rc.d/rsyncd
+-rw-r--r-- root/root etc/rsyncd.conf
+drwxr-xr-x root/root usr/
+drwxr-xr-x root/root usr/bin/
+-rwxr-xr-x root/root usr/bin/rsync
+drwxr-xr-x root/root usr/man/
+drwxr-xr-x root/root usr/man/man1/
+-rw-r--r-- root/root usr/man/man1/rsync.1.gz
+drwxr-xr-x root/root usr/man/man5/
+-rw-r--r-- root/root usr/man/man5/rsyncd.conf.5.gz
+drwxr-xr-x root/root var/
+drwxr-xr-x root/root var/log/
+-rw-r--r-- root/root var/log/rsyncd.log (EMPTY)
diff --git a/rsync/.md5sum b/rsync/.md5sum
new file mode 100644
index 00000000..cb939090
--- /dev/null
+++ b/rsync/.md5sum
@@ -0,0 +1,4 @@
+30c4e2849cbeae93f55548453865c2f2 rsync-2.6.6.tar.gz
+7e01fb425c40a8c10c86f3a80aec9e41 rsync.driver
+a71995f22768c931c5649a1336d25ffb rsyncd
+b4e95fa8c8f3ae13cfdf616abd6a3960 rsyncd.conf
diff --git a/rsync/Pkgfile b/rsync/Pkgfile
new file mode 100644
index 00000000..aba17a5b
--- /dev/null
+++ b/rsync/Pkgfile
@@ -0,0 +1,23 @@
+# Description: Utility for incremental file transfers over networks
+# URL: http://rsync.samba.org
+# Maintainer: Jürgen Daubert, juergen dot daubert at t-online dot de
+# Depends on: openssh
+
+name=rsync
+version=2.6.6
+release=2
+source=(http://samba.org/ftp/$name/$name-$version.tar.gz \
+ rsyncd.conf rsyncd rsync.driver)
+
+build () {
+ cd $name-$version
+ ./configure --prefix=/usr --with-rsh=ssh
+ make
+ make DESTDIR=$PKG install
+
+ mkdir -p $PKG/etc/{rc.d,ports/drivers} $PKG/var/log
+ install -m 755 ../rsyncd $PKG/etc/rc.d
+ install -m 644 ../rsyncd.conf $PKG/etc
+ install -m 755 ../rsync.driver $PKG/etc/ports/drivers/rsync
+ touch $PKG/var/log/rsyncd.log
+}
diff --git a/rsync/rsync.driver b/rsync/rsync.driver
new file mode 100644
index 00000000..10ebc75a
--- /dev/null
+++ b/rsync/rsync.driver
@@ -0,0 +1,142 @@
+#!/usr/bin/perl
+#
+# /etc/ports/drivers/rsync: rsync(1) driver script for ports(8)
+#
+
+use warnings;
+use strict;
+
+my $host = '';
+my $collection = '';
+my $destination = '';
+my %new_checkouts;
+my %old_checkouts;
+
+sub error
+{
+ my $message = shift;
+ print "Error: $message ($!)\nUpdating failed\n";
+ exit 1;
+}
+
+sub warning
+{
+ my $message = shift;
+ print "Warning: $message ($!)\n";
+}
+
+if ($#ARGV < 0)
+{
+ print "Usage: $0 <file>\n";
+ exit 1;
+}
+
+open(FILE, $ARGV[0]) or error("Couldn't open $ARGV[0]");
+while (<FILE>)
+{
+ chomp;
+ if (/^host=(.*)/) { $host = $1; }
+ elsif (/^collection=(.*)/) { $collection = $1; }
+ elsif (/^destination=(.*)/) { $destination = $1; }
+}
+close(FILE);
+
+if ($host eq '') { error("Host field not set in $ARGV[0]"); }
+if ($collection eq '') { error("Collection field not set in $ARGV[0]"); }
+if ($destination eq '') { error("Destination field not set in $ARGV[0]"); }
+
+if (-e "$destination/.checkouts")
+{
+ # read the old .checkouts file into memory
+ open(FILE, "$destination/.checkouts") or error("Couldn't read checkouts from $destination/.checkouts");
+ while (<FILE>)
+ {
+ chomp;
+ $old_checkouts{$_} = 1;
+ }
+ close(FILE);
+}
+
+print "Updating file list from " . $host . "::$collection\n";
+
+# get the remote file list (new .checkouts)
+open(PIPE, 'rsync -crz ' . $host . '::' . $collection . '|') or error("Couldn't open pipe to rsync");
+while (<PIPE>)
+{
+ chomp;
+
+ next if /^MOTD:/; # ignore MOTD lines
+ s/^(.{43})//; # ignore the first 43 characters (mode, date etc...)
+ next if /^.$/; # ignore the . directory
+
+ $new_checkouts{$_} = 1;
+}
+close(PIPE);
+error("Running rsync failed") unless $? == 0;
+
+print "Updating collection $collection\n";
+
+# now really run rsync
+open(PIPE, 'rsync -crz --log-format "%o %n" ' . $host . "::$collection $destination|") or error("Couldn't open pipe to rsync");
+while (<PIPE>)
+{
+ chomp;
+
+ if (/^recv (.*)/)
+ {
+ if ($old_checkouts{$1})
+ {
+ s/^recv/ Edit/;
+ }
+ else
+ {
+ s/^recv/ Checkout/;
+ }
+ }
+
+ print $_ . "\n";
+}
+close(PIPE);
+error("Running rsync failed") unless $? == 0;
+
+# save new checkouts into .checkouts
+open(FILE, ">$destination/.checkouts") or error("Couldn't save checkouts to $destination/.checkouts");
+foreach my $checkout (sort keys %new_checkouts)
+{
+ print FILE "$checkout\n";
+}
+close(FILE);
+
+# use chroot as an additional safety measure when removing files
+chroot($destination) or error("Couldn't chroot into $destination");
+chdir('/');
+
+# iterate through old checkouts, remove obsolete files
+foreach my $checkout (sort keys %old_checkouts)
+{
+ if (!$new_checkouts{$checkout})
+ {
+ if (-f $checkout)
+ {
+ print " Delete $checkout\n";
+ unlink($checkout) or warning("Couldn't delete $checkout");
+ }
+ }
+}
+
+# iterate through old checkouts, remove obsolete directories
+foreach my $checkout (sort keys %old_checkouts)
+{
+ if (!$new_checkouts{$checkout})
+ {
+ if (-d $checkout)
+ {
+ print " Delete $checkout\n";
+ rmdir($checkout) or warning("Couldn't delete $checkout");
+ }
+ }
+}
+
+print "Finished successfully\n";
+
+# End of file
diff --git a/rsync/rsyncd b/rsync/rsyncd
new file mode 100644
index 00000000..85072111
--- /dev/null
+++ b/rsync/rsyncd
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# /etc/rc.d/rsyncd: start/stop rsyncd daemon
+#
+
+case $1 in
+start)
+ /usr/bin/rsync --daemon
+ ;;
+stop)
+ kill `cat /var/run/rsyncd.pid`
+ ;;
+restart)
+ $0 stop
+ sleep 2
+ $0 start
+ ;;
+*)
+ echo "usage: $0 [start|stop|restart]"
+ ;;
+esac
+
+# End of file
diff --git a/rsync/rsyncd.conf b/rsync/rsyncd.conf
new file mode 100644
index 00000000..02bbdc6c
--- /dev/null
+++ b/rsync/rsyncd.conf
@@ -0,0 +1,15 @@
+#
+# /etc/rsyncd.conf
+#
+
+pid file = /var/run/rsyncd.pid
+log file = /var/log/rsyncd.log
+
+[test]
+ path = /tmp
+ comment = test share for rsyncd
+ hosts allow = 192.168.0.0/24
+ read only = true
+ use chroot = true
+
+# End of file

Generated by cgit