From 9106f81c4a81298581dfce7afd4711fa00462cdb Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Fri, 7 Sep 2012 08:58:44 +0200 Subject: [PATCH] removing extra linespaces, comment cleanup --- examples/lalarm.lua | 4 ++-- examples/lbash.lua | 14 +++++++------- examples/lecho.lua | 6 +++--- examples/lftp.lua | 6 +++--- examples/lgforce.lua | 42 ++++++++++++++++++++-------------------- examples/limagemagic.lua | 10 +++++----- examples/lpostcmd.lua | 6 +++--- examples/lrsync.lua | 6 +++--- examples/lsayirc.lua | 12 ++++++------ 9 files changed, 53 insertions(+), 53 deletions(-) diff --git a/examples/lalarm.lua b/examples/lalarm.lua index 64230b9..27515c2 100644 --- a/examples/lalarm.lua +++ b/examples/lalarm.lua @@ -1,8 +1,8 @@ ----- -- User configuration file for lsyncd. --- +-- -- While this example does not do anything it shows --- how user custom alarms can be now. It will log +-- how user custom alarms can be now. It will log -- "Beep!" every 5 seconds. -- settings.nodaemon = true diff --git a/examples/lbash.lua b/examples/lbash.lua index 2f52227..9ac49bb 100644 --- a/examples/lbash.lua +++ b/examples/lbash.lua @@ -1,7 +1,7 @@ ----- -- User configuration file for lsyncd. --- --- This example uses local bash commands to keep two local +-- +-- This example uses local bash commands to keep two local -- directory trees in sync. -- settings = { @@ -28,16 +28,16 @@ bash = { -- calls `cp -r SOURCE/* TARGET` only when there is something in SOURCE -- otherwise it deletes contents in the target if there. onStartup = [[ -if [ "$(ls -A ^source)" ]; then - cp -r ^source* ^target; -else +if [ "$(ls -A ^source)" ]; then + cp -r ^source* ^target; +else if [ "$(ls -A ^target)" ]; then rm -rf ^target/*; fi fi]], onCreate = prefix..[[cp -r ^sourcePath ^targetPathdir]], - + onModify = prefix..[[cp -r ^sourcePath ^targetPathdir]], - + onDelete = prefix..[[rm -rf ^targetPath]], onMove = prefix..[[mv ^o.targetPath ^d.targetPath]], diff --git a/examples/lecho.lua b/examples/lecho.lua index 07f4bf9..2258b9c 100644 --- a/examples/lecho.lua +++ b/examples/lecho.lua @@ -1,7 +1,7 @@ ----- -- User configuration file for lsyncd. --- --- This example uses local bash commands to keep two local +-- +-- This example uses local bash commands to keep two local -- directory trees in sync. -- @@ -11,7 +11,7 @@ echo = { maxProcesses = 1, delay = 1, - onStartup = "/bin/echo telling about ^source", + onStartup = "/bin/echo telling about ^source", onAttrib = "/bin/echo attrib ^pathname", onCreate = "/bin/echo create ^pathname", onDelete = "/bin/echo delete ^pathname", diff --git a/examples/lftp.lua b/examples/lftp.lua index 56b5839..378cfce 100644 --- a/examples/lftp.lua +++ b/examples/lftp.lua @@ -1,8 +1,8 @@ --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- lftp.lua +-- User configuration file for lsyncd. +-- +-- Syncs with 'lftp'. -- --- Syncs with lftp --- A (Layer 1) configuration. --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lftp = { diff --git a/examples/lgforce.lua b/examples/lgforce.lua index 938e11c..dd4a1cd 100644 --- a/examples/lgforce.lua +++ b/examples/lgforce.lua @@ -1,22 +1,22 @@ ----- -- User configuration file for lsyncd. --- --- This example refers to a common problem in unix. --- +-- +-- This example refers to one common challenge in multiuser unix systems. +-- -- You have a shared directory for a set of users and you want -- to ensure all users have read and write permissions on all --- files in there. Unfortunally sometimes users mess with their +-- files in there. Unfortunally sometimes users mess with their -- umask, and create files in there that are not read/write/deleteable -- by others. Usually this involves frequent handfixes by a sysadmin, -- or a cron job that recursively chmods/chowns the whole directory. -- -- This is another approach to use lsyncd to continously fix permissions. --- --- One second after a file is created/modified it checks for its permissions +-- +-- One second after a file is created/modified it checks for its permissions -- and forces group permissions on it. -- -- This example regards more the handcraft of bash scripting than lsyncd. --- An alternative to this would be to load a Lua-Posix library and do the +-- An alternative to this would be to load a Lua-Posix library and do the -- permission changes right within the onAction handlers. ---- @@ -27,29 +27,29 @@ fgroup = "staff" ----- -- script for all changes. -- -command = --- checks if the group is the one enforced and sets them if not +command = +-- checks if the group is the one enforced and sets them if not [[ perm=`stat -c %A ^sourcePathname` if [ `stat -c %G ^sourcePathname` != ]]..fgroup..[[ ]; then - /bin/chgrp ]]..fgroup..[[ ^sourcePathname || /bin/true; -fi + /bin/chgrp ]]..fgroup..[[ ^sourcePathname || /bin/true; +fi ]] .. --- checks if the group permissions are rw and sets them +-- checks if the group permissions are rw and sets them [[ -if [ `expr match $perm "....rw"` == 0 ]; then - /bin/chmod g+rw ^sourcePathname || /bin/true; -fi +if [ `expr match $perm "....rw"` == 0 ]; then + /bin/chmod g+rw ^sourcePathname || /bin/true; +fi ]] .. -- and forces the executable bit for directories. [[ if [ -d ^sourcePathname ]; then - if [ `expr match $perm "......x"` == 0 ]; then + if [ `expr match $perm "......x"` == 0 ]; then /bin/chmod g+x ^^sourcePathname || /bin/true; - fi -fi + fi +fi ]] -- on startup recursevily sets all group ownerships @@ -58,11 +58,11 @@ fi -- -- the carret as first char tells Lsycnd to call a shell altough it -- starts with a slash otherwisw --- -startup = +-- +startup = [[^/bin/chgrp -R ]]..fgroup..[[ ^source || /bin/true && /bin/chmod -R g+rw ^source || /bin/true && -/usr/bin/find ^source -type d | xargs chmod g+x +/usr/bin/find ^source -type d | xargs chmod g+x ]] gforce = { diff --git a/examples/limagemagic.lua b/examples/limagemagic.lua index 1a2eb6d..1990b53 100644 --- a/examples/limagemagic.lua +++ b/examples/limagemagic.lua @@ -1,6 +1,6 @@ ---- -- Lsyncd user-script that creates a "magic" image converter directory. --- +-- -- This configuration will automatically convert all images that are placed -- in the directory 'magicdir' all resulting images are placed in the same -- directory! @@ -50,7 +50,7 @@ convert = { if cmd ~= "" then cmd = cmd .. " && " end - cmd = cmd.. + cmd = cmd.. '/usr/bin/convert "'.. event.source..p..'" "'.. event.source..base..'.'..k.. @@ -61,7 +61,7 @@ convert = { spawnShell(event, cmd) return end - + -- deletes all formats if you delete one if event.etype == "Delete" then -- builds one bash command @@ -99,8 +99,8 @@ convert = { local inlet = event.inlet if event.etype == "Create" or - event.etype == "Modify" or - event.etype == "Delete" + event.etype == "Modify" or + event.etype == "Delete" then for k, _ in pairs(formats) do inlet.rmExclude(base..'.'..k) diff --git a/examples/lpostcmd.lua b/examples/lpostcmd.lua index 2f5b5a2..e11639b 100644 --- a/examples/lpostcmd.lua +++ b/examples/lpostcmd.lua @@ -26,12 +26,12 @@ local rsyncpostcmd = { -- triggering an error if not. local isPostcmd = rawget(event, "isPostcmd") if event.isPostcmd then - spawn(event, "/usr/bin/ssh", + spawn(event, "/usr/bin/ssh", config.host, config.postcmd) return else -- this is the startup, forwards it to default routine. - return default.rsync.action(inlet) + return default.rsync.action(inlet) end error("this should never be reached") end @@ -78,7 +78,7 @@ local rsyncpostcmd = { sync { - rsyncpostcmd, + rsyncpostcmd, source = "src", host = "beetle", targetdir = "/path/to/trg", diff --git a/examples/lrsync.lua b/examples/lrsync.lua index 378fe07..db23982 100644 --- a/examples/lrsync.lua +++ b/examples/lrsync.lua @@ -9,8 +9,8 @@ settings = { } sync{ - default.rsync, - source="src", - target="trg", + default.rsync, + source="src", + target="trg", } diff --git a/examples/lsayirc.lua b/examples/lsayirc.lua index 49c44ae..c9716b6 100644 --- a/examples/lsayirc.lua +++ b/examples/lsayirc.lua @@ -1,7 +1,7 @@ ----- -- An Lsyncd+IRC-Bot Config -- --- Logs into an IRC channel and tells there everything that happens in the +-- Logs into an IRC channel and tells there everything that happens in the -- watched directory tree. -- -- The challenge coding Lsyncd configs taking use of TCP sockets is @@ -10,7 +10,7 @@ -- no longer spawning processes (this example doesnt do any, but maybe you -- might want to do that as well), blocking is just bad. -- --- This demo codes just minimal IRC functionality. +-- This demo codes just minimal IRC functionality. -- it does not respond to anything else than IRC PING messages. -- -- There is no flood control, if a lot happens the IRC server will disconnect @@ -55,7 +55,7 @@ local function ircWritey(fd) end ---- --- Called when there is data on the socket +-- Called when there is data on the socket local function ircReady(socket) local l, err, ircRBuf = ircSocket:receive("*l", ircRBuf) if not l then @@ -88,7 +88,7 @@ function writeIRC(...) log("Error", "IRC connection failed: ", err) terminate(-1) end - + --- logs what has been send, without the linefeed. if (ircWBuf:sub(s, s) == "\n") then log("Normal", "ircout:", ircWBuf:sub(1, s - 1)) @@ -133,8 +133,8 @@ local function action(inlet) end -- Watch a directory, and use a second for delay to aggregate events a little. -sync{source = "src", - action = action, +sync{source = "src", + action = action, delay = 1, onMove = true}