[Csync2] Patch: do-local-only in action

Robert Heinzmann (ml) reg at elconas.de
Mon May 19 11:37:44 CEST 2008


Hello list,

yesterday I asked about the "do local only" facilities of csync2 and 
today I found that I used the wrong e-Mail Address for sending :)

While studying the code I found that the latest svn version did not 
contains such a thing.

Attached a patch that enables the "do-local-only;" config setting to 
execute actions only on the source machine.

The patch is agains the latest SVN version at svn.linbit.at

Regards
Robert

-- 
Robert Heinzmann


-------------- next part --------------
Index: cfgfile_parser.y
===================================================================
--- cfgfile_parser.y	(revision 396)
+++ cfgfile_parser.y	(working copy)
@@ -304,6 +304,12 @@
 	csync_group->action->do_local = 1;
 }
 
+static void set_action_dolocal_only()
+{
+	csync_group->action->do_local = 1;
+	csync_group->action->do_local_only = 1;
+}
+
 static void new_prefix(const char *pname)
 {
 	struct csync_prefix *p =
@@ -395,7 +401,7 @@
 %token TK_NOSSL TK_IGNORE TK_GROUP TK_HOST TK_EXCL TK_INCL TK_COMP TK_KEY
 %token TK_ACTION TK_PATTERN TK_EXEC TK_DOLOCAL TK_LOGFILE TK_NOCYGLOWER
 %token TK_PREFIX TK_ON TK_COLON TK_POPEN TK_PCLOSE
-%token TK_BAK_DIR TK_BAK_GEN
+%token TK_BAK_DIR TK_BAK_GEN TK_DOLOCALONLY
 %token <txt> TK_STRING
 
 %%
@@ -517,6 +523,8 @@
 		{ set_action_logfile($2); }
 |	TK_DOLOCAL
 		{ set_action_dolocal(); }
+|	TK_DOLOCALONLY
+		{ set_action_dolocal_only(); }
 ;
 
 action_pattern_list:
Index: csync2.h
===================================================================
--- csync2.h	(revision 396)
+++ csync2.h	(working copy)
@@ -253,6 +253,7 @@
 	struct csync_group_action_command *command;
 	const char *logfile;
 	int do_local;
+	int do_local_only;
 };
 
 struct csync_group {
Index: action.c
===================================================================
--- action.c	(revision 396)
+++ action.c	(working copy)
@@ -38,6 +38,8 @@
 
 	while ( (g=csync_find_next(g, filename)) ) {
 		for (a=g->action; a; a=a->next) {
+			if ( !islocal && a->do_local_only )
+				continue;
 			if ( islocal && !a->do_local )
 				continue;
 			if (!a->pattern)
Index: csync2.cfg
===================================================================
--- csync2.cfg	(revision 396)
+++ csync2.cfg	(working copy)
@@ -39,6 +39,9 @@
 # 		exec "/usr/sbin/apache2ctl graceful";
 # 		logfile "/var/log/csync2_action.log";
 # 		do-local;
+#		# you can use do-local-only if the execution
+#		# should be done locally only
+#		# do-local-only;
 # 	}
 #
 # 	# The backup-directory needs to be created first!
Index: cfgfile_scanner.l
===================================================================
--- cfgfile_scanner.l	(revision 396)
+++ cfgfile_scanner.l	(working copy)
@@ -56,6 +56,7 @@
 "exec"		{ return TK_EXEC; }
 "logfile"	{ return TK_LOGFILE; }
 "do-local"	{ return TK_DOLOCAL; }
+"do-local-only"	{ return TK_DOLOCALONLY; }
 
 "prefix"	{ return TK_PREFIX; }
 "on"		{ return TK_ON; }
Index: doc/csync2_paper.tex
===================================================================
--- doc/csync2_paper.tex	(revision 396)
+++ doc/csync2_paper.tex	(working copy)
@@ -231,6 +231,7 @@
                 exec "/usr/sbin/apache2ctl graceful";
                 logfile "/var/log/csync2_action.log";
                 do-local;
+		# do-local-only;
         }
 
         backup-directory /var/backups/csync2;
@@ -379,7 +380,8 @@
 Usually the action is only triggered on the targed hosts, not on the host on
 which the file modification has been detected in the first place. The {\tt
 do-local} statement can be used to change this behavior and let \csync2 also
-execute the command on the host from which the modification originated.
+execute the command on the host from which the modification originated. You can 
+use {\ttdo-local-only} to execute the action only on this machine. 
 
 \subsubsection{Conflict Auto-resolving}
 
Index: autogen.sh
===================================================================
--- autogen.sh	(revision 396)
+++ autogen.sh	(working copy)
@@ -18,9 +18,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-aclocal-1.7
+aclocal
 autoheader
-automake-1.7 --add-missing --copy
+automake --add-missing --copy
 autoconf
 
 if [ "$1" = clean ]; then


More information about the Csync2 mailing list