From 297f110d1fb6ec3550bc5663d0786810026d5a17 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Wed, 27 Oct 2010 11:31:18 +0000 Subject: [PATCH] --- configure.ac | 2 +- lsyncd-conf.lua | 17 +++++++---------- lsyncd.lua | 10 +++++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index e79658f..5187b66 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. #AC_PREREQ(2.60) -AC_INIT(lsyncd, 2.0b1, axkibe@gmail.com) +AC_INIT(lsyncd, 2.0beta1, axkibe@gmail.com) AC_CONFIG_SRCDIR([lsyncd.c]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE(lsyncd, main) diff --git a/lsyncd-conf.lua b/lsyncd-conf.lua index 68ad57a..e579d13 100644 --- a/lsyncd-conf.lua +++ b/lsyncd-conf.lua @@ -13,30 +13,27 @@ settings = { ------ -- for testing purposes -- -slower = "sleep 1 && " +prefix = "sleep 1 && " slowbash = { delay = 5, startup = function(source, target) log(NORMAL, "cp -r from "..source.." -> "..target) - return exec("/bin/bash", "-c", [[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]], - "/bin/bash", source, target) + return shell([[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]], source, target) end, create = function(source, path, name, target) local src = source..path..name local trg = target..path..name log(NORMAL, "create from "..src.." -> "..trg) - return exec("/bin/bash", "-c", slower..[[cp "$1" "$2"]], - "/bin/bash", src, trg) + return shell(prefix..[[cp "$1" "$2"]], src, trg) end, modify = function(source, path, name, target) local src = source..path..name local trg = target..path..name log(NORMAL, "modify from "..src.." -> "..trg) - return exec("/bin/bash", "-c", slower..[[cp "$1" "$2"]], - "/bin/bash", src, trg) + return shell(prefix..[[cp "$1" "$2"]], src, trg) end, attrib = function(source, path, name, target) @@ -45,9 +42,9 @@ slowbash = { end, delete = function(source, path, name, target) - log(NORMAL, "delete "..target..path..name) - return exec("/bin/bash", "-c", slower..[[rm "$1"]], - "/bin/bash", target..path..name) + local trg = target..path..name + log(NORMAL, "delete "..trg) + return exec(prefix..[[rm "$1"]], trg) end, -- move = function(source, path, name, destpath, destname, target) diff --git a/lsyncd.lua b/lsyncd.lua index 85a6e11..6253495 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -19,7 +19,7 @@ if lsyncd_version then print("You cannot use the lsyncd runner as configuration file!") os.exit(-1) end -lsyncd_version = "2.0b1" +lsyncd_version = "2.0beta1" ---- -- Shortcuts (which user is supposed to be able to use them as well) @@ -658,6 +658,7 @@ end ---- -- Called by core when an overflow happened. +-- function default_overflow() log(ERROR, "--- OVERFLOW on inotify event queue ---") lsyncd.terminate(-1) -- TODO reset instead. @@ -665,6 +666,13 @@ function default_overflow() end overflow = default_overflow +----- +-- Spawns a child process using bash. +-- +function shell(command, ...) + return exec("/bin/sh", "-c", command, "/bin/sh", ...) +end + --============================================================================ -- lsyncd default settings --============================================================================