summaryrefslogtreecommitdiffstats
path: root/rsync
diff options
context:
space:
mode:
authorLukc <lukc@upyum.com>2010-12-11 19:15:23 +0100
committerLukc <lukc@upyum.com>2010-12-11 19:15:35 +0100
commit6d908a38e05b9d4135c65d23114a5874215b5bb8 (patch)
treeb5e6da6d95b9a1235d82032b509b80483a886ff5 /rsync
downloadbase-6d908a38e05b9d4135c65d23114a5874215b5bb8.tar.gz
base-6d908a38e05b9d4135c65d23114a5874215b5bb8.tar.bz2
base-6d908a38e05b9d4135c65d23114a5874215b5bb8.tar.xz
base-6d908a38e05b9d4135c65d23114a5874215b5bb8.zip
Engagement initial.
Diffstat (limited to 'rsync')
-rw-r--r--rsync/.footprint18
-rw-r--r--rsync/.md5sum4
-rw-r--r--rsync/Pkgfile22
-rw-r--r--rsync/Pkgfile.old28
-rw-r--r--rsync/rsync.driver143
-rw-r--r--rsync/rsyncd23
-rw-r--r--rsync/rsyncd.conf15
7 files changed, 253 insertions, 0 deletions
diff --git a/rsync/.footprint b/rsync/.footprint
new file mode 100644
index 0000000..dbb4683
--- /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 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/Pkgfile b/rsync/Pkgfile
new file mode 100644
index 0000000..1272713
--- /dev/null
+++ b/rsync/Pkgfile
@@ -0,0 +1,22 @@
+description="Utility for incremental file transfers over networks"
+packager=""
+maintainer="CRUX System Team, core-ports at crux dot nu"
+url="http://rsync.samba.org"
+depends=(openssh acl)
+
+name=rsync
+version=3.0.7
+release=1
+source=(http://rsync.samba.org/ftp/rsync/src/rsync-3.0.7.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/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