# HG changeset patch # User Matthias Förste # Date 1487166069 -3600 # Node ID c5026a0ae75705277aac40a3e32b602c960e6765 # Parent a589fb3599fb12dc02e86598d761ebfc60a1d92e moved to git diff -r a589fb3599fb -r c5026a0ae757 Makefile --- a/Makefile Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -DESTDIR = - -package = wgnd-watch -prefix ?= /usr/local -datarootdir = $(prefix)/share -sbindir = $(prefix)/sbin -docdir = $(datarootdir)/doc/$(package) -mandir = $(datarootdir)/man -sbinscripts = $(package) - -rcdir = /etc/init.d - -%: %.pl - cp -a $< $@ -%.1: %.pl - pod2man $< $@ - -rc.%: rc.%.in - perl -pe 's{__sbindir__}{${sbindir}}g' <$< >$@ - -all: $(package) $(package).1 rc.$(package) - -install: all - install -m 0755 -d $(DESTDIR)$(sbindir) - install -m 0755 $(sbinscripts) $(DESTDIR)$(sbindir) - install -m 0755 -d $(DESTDIR)$(docdir) - install -m 0755 $(package).map.pl.ex $(DESTDIR)$(docdir) - install -m 0755 -d $(DESTDIR)$(mandir)/man1 - install -m 0755 $(package).1 $(DESTDIR)$(mandir)/man1 - install -m 0755 -d $(DESTDIR)$(rcdir) - install -m 0755 rc.$(package) $(DESTDIR)$(rcdir)/$(package) - -clean: - -rm -f $(package) $(package).1 rc.$(package) diff -r a589fb3599fb -r c5026a0ae757 README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Wed Feb 15 14:41:09 2017 +0100 @@ -0,0 +1,1 @@ +moved to git://git.schlittermann.de/wiegand/wgnd-watch diff -r a589fb3599fb -r c5026a0ae757 debian/changelog --- a/debian/changelog Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -wgnd-watch (0.3) oldstable stable; urgency=medium - - * made rsync args an argument because users wants to keep mtimes; updated - copyright years - - -- Matthias Förste Mon, 13 Feb 2017 16:53:08 +0100 - -wgnd-watch (0.2) oldstable stable; urgency=medium - - * $ENV{HOME} may be unset which would produce a warning - * lintian warnings - - -- Matthias Förste Thu, 03 Dec 2015 09:35:20 +0100 - -wgnd-watch (0.1) squeeze; urgency=low - - * Initial Release. - - -- Matthias Förste Thu, 03 May 2012 22:35:39 +0200 diff -r a589fb3599fb -r c5026a0ae757 debian/compat --- a/debian/compat Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 diff -r a589fb3599fb -r c5026a0ae757 debian/control --- a/debian/control Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -Source: wgnd-watch -Section: misc -Priority: extra -Maintainer: Matthias Förste -Build-Depends: debhelper (>= 7.0.50~) -Standards-Version: 3.9.6 -Homepage: https://ssl.schlittermann.de/hg/ius/wgnd-watch -#Vcs-hg: https://ssl.schlittermann.de/hg/ius/wgnd-watch -#Vcs-Browser: https://ssl.schlittermann.de/hg/ius/wgnd-watch - -Package: wgnd-watch -Architecture: all -Depends: ${misc:Depends}, ${perl:Depends}, liblinux-inotify2-perl, rsync -Description: inotify actions for wiegand - wgnd-watch currently watches some directories for newly created subdirectories - and synchronises these from a given template directory. diff -r a589fb3599fb -r c5026a0ae757 debian/copyright --- a/debian/copyright Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -This work was packaged for Debian by: - - Matthias Förste on Thu, 26 Apr 2012 11:38:51 +0200 - -It was downloaded from: - - https://ssl.schlittermann.de/hg/ius/wgnd-watch - -Upstream Author: - - Matthias Förste - -Copyright: - - Copyright (C) 2012-2017 Matthias Förste - -License: - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -On Debian systems, the complete text of the GNU General -Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". - -The Debian packaging is: - - Copyright (C) 2012-2017 Matthias Förste - -and is licensed under the GPL version 3, see above. diff -r a589fb3599fb -r c5026a0ae757 debian/rules --- a/debian/rules Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -%: - prefix='/usr' dh $@ - -override_dh_installinit: - dh_installinit -o diff -r a589fb3599fb -r c5026a0ae757 debian/source/format --- a/debian/source/format Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -3.0 (native) diff -r a589fb3599fb -r c5026a0ae757 rc.wgnd-watch.in --- a/rc.wgnd-watch.in Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -#! /bin/sh - -### BEGIN INIT INFO -# Provides: wgnd-watch -# Required-Start: $local_fs $remote_fs $syslog $named $network $time -# Required-Stop: $local_fs $remote_fs $syslog $named $network -# Should-Start: -# Should-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start/Stop the wgnd-watch daemon -### END INIT INFO - -DAEMON=__sbindir__/wgnd-watch -PIDFILE=/var/run/`basename $DAEMON`.pid - -. /lib/lsb/init-functions - -case $1 in - - start) - start-stop-daemon -v --start --pidfile $PIDFILE --startas $DAEMON - ;; - - stop) - start-stop-daemon -v --stop --retry 30 --pidfile $PIDFILE - ;; - - force-reload|restart) echo "Restarting $NAME..." - $0 stop - $0 start - ;; - - *) - echo "Usage: $0 {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff -r a589fb3599fb -r c5026a0ae757 wgnd-watch.map.pl.ex --- a/wgnd-watch.map.pl.ex Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -our $source = { - '/tmp' => './' -}; diff -r a589fb3599fb -r c5026a0ae757 wgnd-watch.pl --- a/wgnd-watch.pl Wed Feb 15 12:45:01 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,238 +0,0 @@ -#!/usr/bin/perl - -# Copyright (C) 2012-2017 Matthias Förste -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# Matthias Förste - -=encoding utf8 -=cut - -use strict; -use warnings; - -my $VERSION = '0.1'; -my $ME = $0; - -use File::Basename; - -# File::Rsync in squeeze does not support --xattrs yet -#use File::Rsync; -use Getopt::Long; -use Pod::Usage; -use Linux::Inotify2; -use Sys::Syslog; - -my $master; - -BEGIN { - - openlog($ME, 'ndelay,nowait,pid', 'LOG_USER'); - $SIG{__WARN__} = sub { - warn @_ if not defined $^S; - print STDERR "@_"; - syslog('warning', "@_"); - }; - $SIG{__DIE__} = sub { - die @_ if not defined $^S; - print STDERR "@_"; - syslog('err', "@_"); - exit $?; - }; - sub dolog { print "@_"; syslog('info', "@_"); } - sub trace { print @_ if $ENV{DEBUG}; } - - use sigtrap qw(die normal-signals); - -} - -my %opts = ( - daemon => 1, - map => 'wgnd-watch.map.pl', - pidfile => '/var/run/wgnd-watch.pid', - 'rsync-args' => [ qw(-ihv -aAX --no-times) ], - 'rsync-cmd' => '/usr/bin/rsync' -); - -GetOptions( - "map=s" => \$opts{map}, - "daemon!" => \$opts{daemon}, - "pidfile=s" => \$opts{pidfile}, - "rsync-args=s@" => \$opts{'rsync-args'}, - "rsync-cmd=s" => \$opts{'rsync-cmd'}, - "h|help!" => sub { pod2usage(-verbose => 0, -exitval => 0) }, - "m|man!" => sub { - pod2usage( - -verbose => 2, - -exitval => 0, - -noperldoc => (`perldoc -V 2>/dev/null`, $? != 0)[-1] - ); - }, -) or pod2usage(); - -our $source; -use lib grep { defined } ('.', $ENV{HOME}, '/etc'); -require $opts{map}; - -$0 = "$ME @ARGV"; - -chdir("/") or die "Can't chdir to /: $!\n"; - -if ($opts{daemon}) { - - open STDIN, "/dev/null" or die "Can't redir STDOUT: $!\n"; - - defined(my $pid = fork) or die "Can't fork: $!\n"; - if ($pid) { - dolog "Child is [$pid]"; - exit 0; - } - POSIX::setsid() - or die "Can't setsid: $!\n"; - open(STDERR, ">&STDOUT") or die "Can't dup stdout: $!\n"; - - open(P, '>', $opts{pidfile}) - or die "Can't open '>', '$opts{pidfile}': $!\n"; - print P $$; - close P; - $master = $$; - -} - -my $inotify = new Linux::Inotify2 - or die "Can't create new inotify object: $!\n"; -my @rsync = ($opts{'rsync-cmd'}, @{$opts{'rsync-args'}}); - -for (keys %{$source}) { - - # add watchers - $inotify->watch( - "$_", - IN_CREATE, - sub { - - my $pid = fork; - - if (not defined $pid) { - warn "Can't fork: $!\n"; - } elsif ($pid == 0) { - my $e = shift; - my $name = $e->fullname; - dolog "$name was created\n" if $e->IN_CREATE; - dolog "$name is no longer mounted\n" if $e->IN_UNMOUNT; - dolog "$name is gone\n" if $e->IN_IGNORED; - dolog "events for $name have been lost\n" if $e->IN_Q_OVERFLOW; - exec @rsync, $source->{ $e->{w}->{name} }, $name; - warn "Can't exec: $!\n"; - } - - } - ) or die "Can't add watch: $!\n"; -} - -while (1) { - - $inotify->poll; - while (-1 != (my $pid = wait)) { - my $e = $? >> 8; - dolog "Child ${ME}[$pid]: exit $e\n"; - } - -} - -END { - - unlink $opts{pidfile} - if $opts{daemon} - and defined $master - and $master eq $$; - dolog "exit"; - closelog; - -} - -__END__ - -=pod - -=head1 NAME - -wgnd-watch - inotify actions for wiegand - -=head1 SYNOPSIS - -wgnd-watch [--map filename] - -wgnd-watch -m|--man - -h|--help - -=head1 DESCRIPTION - -wgnd-watch currently watches some directories for newly created subdirectories -and synchronises these from a given template directory. - -=head1 OPTIONS - -=over - -=item B<--[no]daemon> - -[Don't] run as a daemon. Default: do. - -=item B<--map> I - -Name of a file containing mappings between templates and directories. Defaults -to F. - -=item B<--pidfile> I - -Location of the pid file. This is ignored unless we are running as a daemon. -Defaults to F. - -=item B<--pidfile> I - -Location of the pid file. This is ignored unless we are running as a daemon. -Defaults to F. - -=item B<--rsync-args> I - -Arguments to pass to the rsync command. May be given multiple times. Defaults to B<-ihv -aAX --no-times>. - -=item B<--rsync-cmd> I - -Rsync Command. Defaults to F. - -=back - -=head1 FILES - -=over - -=item F - -default for B<--map> - -=item F - -default for B<--pidfile> - -=back - -=head1 AUTHOR - -Matthias Förste - -=cut