summaryrefslogtreecommitdiffstats
path: root/rsync
diff options
context:
space:
mode:
authorLukc <lukc@upyum.com>2010-12-12 04:47:45 +0100
committerLukc <lukc@upyum.com>2010-12-12 04:47:45 +0100
commitf3d2975053ac056d84e872af7498a51d3d81fbd2 (patch)
tree66156d51cf44f30e7322f453e01134dddba10ca9 /rsync
parentc42d52ef73123d38394acaa646ff82d0e5aff6a9 (diff)
downloadopt-f3d2975053ac056d84e872af7498a51d3d81fbd2.tar.gz
opt-f3d2975053ac056d84e872af7498a51d3d81fbd2.tar.bz2
opt-f3d2975053ac056d84e872af7498a51d3d81fbd2.tar.xz
opt-f3d2975053ac056d84e872af7498a51d3d81fbd2.zip
Recette de rsync ajoutée.
Diffstat (limited to 'rsync')
-rw-r--r--rsync/.footprint19
-rw-r--r--rsync/.md5sum4
-rw-r--r--rsync/.sha256sum4
-rw-r--r--rsync/Pkgfile27
-rw-r--r--rsync/Pkgfile.old28
-rw-r--r--rsync/rsync.driver143
-rw-r--r--rsync/rsyncd23
-rw-r--r--rsync/rsyncd.conf15
8 files changed, 263 insertions, 0 deletions
diff --git a/rsync/.footprint b/rsync/.footprint
new file mode 100644
index 0000000..d66d7a9
--- /dev/null
+++ b/rsync/.footprint
@@ -0,0 +1,19 @@
+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/share/
+drwxr-xr-x root/root usr/share/man/
+drwxr-xr-x root/root usr/share/man/man1/
+-rw-r--r-- root/root usr/share/man/man1/rsync.1.bz2
+drwxr-xr-x root/root usr/share/man/man5/
+-rw-r--r-- root/root usr/share/man/man5/rsyncd.conf.5.bz2
+drwxr-xr-x root/root var/
+drwxr-xr-x root/root var/log/
+-rw-r--r-- root/root var/log/rsyncd.log
diff --git a/rsync/.md5sum b/rsync/.md5sum
new file mode 100644
index 0000000..25d5822
--- /dev/null
+++ b/rsync/.md5sum
@@ -0,0 +1,4 @@
+b53525900817cf1ba7ad3a516ab5bfe9 rsync-3.0.7.tar.gz
+f8dcfe5cf2afef1ea90107a6ff4540cd rsync.driver
+a71995f22768c931c5649a1336d25ffb rsyncd
+b4e95fa8c8f3ae13cfdf616abd6a3960 rsyncd.conf
diff --git a/rsync/.sha256sum b/rsync/.sha256sum
new file mode 100644
index 0000000..da18ddd
--- /dev/null
+++ b/rsync/.sha256sum
@@ -0,0 +1,4 @@
+9ee00d16c023c486328cbb61f59928a954b24b7b7173c3517ebb0d6c3edfe7c8 rsync-3.0.7.tar.gz
+ac6bf54e13f15e21090c0dcda5f9b8be8ea391baae34ac0b0eed04ac46d22232 rsync.driver
+4e21a3635ae2e9ad3ed7e013fd8b4bb6937327a5c1855379c505637616237ea9 rsyncd
+095447801d8ba0101809c18acfb5a492c65323bed9ef5dd3739b3af5e9f7c56d rsyncd.conf
diff --git a/rsync/Pkgfile b/rsync/Pkgfile
new file mode 100644
index 0000000..7c895f1
--- /dev/null
+++ b/rsync/Pkgfile
@@ -0,0 +1,27 @@
+description="Utility for incremental file transfers over networks."
+packager="CRUX System Team <core-ports AT crux DOT nu>"
+maintainer="Lukc <lukc AT upyum DOT com>"
+url="http://rsync.samba.org"
+depends=(openssh acl)
+
+name=rsync
+version=3.0.7
+release=1
+source=(
+ http://rsync.samba.org/ftp/rsync/src/$name-$version.tar.gz
+ rsyncd.conf
+ rsyncd
+ rsync.driver
+)
+build ()
+{
+ cd $name-$version;
+ ./configure --prefix=$prefix --mandir=$mandir --with-rsh=ssh --with-included-popt;
+ make;
+ make DESTDIR=$PKG install;
+ install -d $PKG/etc/{rc.d,ports/drivers} $PKG/var/log;
+ install -m 755 $SRC/rsyncd $PKG/etc/rc.d;
+ install -m 644 $SRC/rsyncd.conf $PKG/etc;
+ install -m 755 $SRC/rsync.driver $PKG/etc/ports/drivers/rsync;
+ touch $PKG/var/log/rsyncd.log
+}
diff --git a/rsync/Pkgfile.old b/rsync/Pkgfile.old
new file mode 100644
index 0000000..6435b97
--- /dev/null
+++ b/rsync/Pkgfile.old
@@ -0,0 +1,28 @@
+# Description: Utility for incremental file transfers over networks
+# URL: http://rsync.samba.org
+# Maintainer: CRUX System Team, core-ports at crux dot nu
+# Depends on: openssh acl
+
+name=rsync
+version=3.0.7
+release=1
+source=(http://rsync.samba.org/ftp/$name/src/$name-$version.tar.gz \
+ rsyncd.conf rsyncd rsync.driver)
+
+build () {
+ cd $name-$version
+
+ ./configure --prefix=/usr \
+ --mandir=/usr/man \
+ --with-rsh=ssh \
+ --with-included-popt
+
+ make
+ make DESTDIR=$PKG install
+
+ install -d $PKG/etc/{rc.d,ports/drivers} $PKG/var/log
+ install -m 755 $SRC/rsyncd $PKG/etc/rc.d
+ install -m 644 $SRC/rsyncd.conf $PKG/etc
+ install -m 755 $SRC/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 0000000..31bb14a
--- /dev/null
+++ b/rsync/rsync.driver
@@ -0,0 +1,143 @@
+#!/usr/bin/perl
+#
+# /etc/ports/drivers/rsync: rsync(1) driver script for ports(8)
+#
+
+use warnings;
+use strict;
+use File::Basename;
+
+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 " . basename($destination) . "\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 0000000..8507211
--- /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 0000000..02bbdc6
--- /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