mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-04 19:03:17 +00:00
cleanups
This commit is contained in:
parent
2fb819d992
commit
36a13acd2b
@ -11,7 +11,7 @@ include_directories ( ${LUA_INCLUDE_DIR} )
|
||||
|
||||
|
||||
# setting Lsyncd sources
|
||||
set( LSYNCD_SRC core.c luacode.c )
|
||||
set( LSYNCD_SRC core/core.c luacode.c )
|
||||
|
||||
# tell systemd via the sd-daemon library about the status of Lsyncd
|
||||
option( WITH_SYSTEMD "Communicate Lsyncd status to systemd" ON )
|
||||
@ -20,9 +20,10 @@ option( WITH_SYSTEMD "Communicate Lsyncd status to systemd" ON )
|
||||
option( WITH_INOTIFY "Compile with inotify file notifications (Linux)" ON )
|
||||
|
||||
if( WITH_INOTIFY )
|
||||
set( LSYNCD_SRC ${LSYNCD_SRC} inotify.c )
|
||||
set( LSYNCD_SRC ${LSYNCD_SRC} core/inotify.c )
|
||||
endif( WITH_INOTIFY )
|
||||
|
||||
|
||||
# generating the config.h file
|
||||
configure_file (
|
||||
"${PROJECT_SOURCE_DIR}/config.h.in"
|
||||
@ -32,14 +33,13 @@ include_directories("${PROJECT_BINARY_DIR}")
|
||||
|
||||
|
||||
# building and compiling the part of lsyncd written in Lua
|
||||
# also called "runner"
|
||||
|
||||
set( LUA_CODE
|
||||
${PROJECT_SOURCE_DIR}/lsyncd.lua
|
||||
${PROJECT_SOURCE_DIR}/default.lua
|
||||
${PROJECT_SOURCE_DIR}/default-rsync.lua
|
||||
${PROJECT_SOURCE_DIR}/default-rsyncssh.lua
|
||||
${PROJECT_SOURCE_DIR}/default-direct.lua
|
||||
${PROJECT_SOURCE_DIR}/default/default.lua
|
||||
${PROJECT_SOURCE_DIR}/default/rsync.lua
|
||||
${PROJECT_SOURCE_DIR}/default/rsyncssh.lua
|
||||
${PROJECT_SOURCE_DIR}/default/direct.lua
|
||||
)
|
||||
|
||||
add_custom_command( OUTPUT luacode.c
|
||||
@ -61,6 +61,7 @@ add_custom_target( manpage
|
||||
DEPENDS doc/manpage/lsyncd.1.txt
|
||||
)
|
||||
|
||||
# the test suite
|
||||
add_custom_target( tests
|
||||
COMMAND echo "Running the tests"
|
||||
COMMAND echo "Note you are expected to:"
|
||||
|
@ -3,4 +3,3 @@
|
||||
|
||||
/* File event notification mechanims available */
|
||||
#cmakedefine WITH_INOTIFY 1
|
||||
#cmakedefine WITH_FSEVENTS 1
|
||||
|
@ -18,17 +18,11 @@
|
||||
--
|
||||
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if not default then
|
||||
error('default not loaded')
|
||||
end
|
||||
if not default then error( 'default not loaded' ) end
|
||||
|
||||
if not default.rsync then
|
||||
error('default-direct (currently) needs default.rsync loaded')
|
||||
end
|
||||
if not default.rsync then error( 'default-direct needs default.rsync loaded' ) end
|
||||
|
||||
if default.direct then
|
||||
error('default-direct already loaded')
|
||||
end
|
||||
if default.direct then error( 'default-direct already loaded' ) end
|
||||
|
||||
local direct = { }
|
||||
|
||||
@ -38,7 +32,8 @@ default.direct = direct
|
||||
--
|
||||
-- known configuration parameters
|
||||
--
|
||||
direct.checkgauge = {
|
||||
direct.checkgauge =
|
||||
{
|
||||
--
|
||||
-- inherits rsync config params
|
||||
--
|
||||
@ -52,19 +47,20 @@ direct.checkgauge = {
|
||||
--
|
||||
-- Spawns rsync for a list of events
|
||||
--
|
||||
direct.action = function(inlet)
|
||||
direct.action =
|
||||
function
|
||||
(
|
||||
inlet
|
||||
)
|
||||
-- gets all events ready for syncing
|
||||
local event, event2 = inlet.getEvent()
|
||||
local config = inlet.getConfig()
|
||||
|
||||
if event.etype == 'Create' then
|
||||
if event.isdir then
|
||||
spawn(
|
||||
event,
|
||||
'/bin/mkdir',
|
||||
'--',
|
||||
event.targetPath
|
||||
)
|
||||
if event.etype == 'Create'
|
||||
then
|
||||
if event.isdir
|
||||
then
|
||||
spawn( event, '/bin/mkdir', '--', event.targetPath )
|
||||
else
|
||||
-- 'cp -t', not supported on OSX
|
||||
spawn(
|
||||
@ -76,22 +72,18 @@ direct.action = function(inlet)
|
||||
event.targetPathdir
|
||||
)
|
||||
end
|
||||
elseif event.etype == 'Modify' then
|
||||
if event.isdir then
|
||||
error("Do not know how to handle 'Modify' on dirs")
|
||||
elseif event.etype == 'Modify'
|
||||
then
|
||||
if event.isdir
|
||||
then
|
||||
error( 'Do not know how to handle "Modify" on dirs' )
|
||||
end
|
||||
spawn(event,
|
||||
'/bin/cp',
|
||||
'-p',
|
||||
'--',
|
||||
event.sourcePath,
|
||||
event.targetPathdir
|
||||
)
|
||||
elseif event.etype == 'Delete' then
|
||||
|
||||
if
|
||||
config.delete ~= true and
|
||||
config.delete ~= 'running'
|
||||
spawn(event, '/bin/cp', '-p', '--', event.sourcePath, event.targetPathdir )
|
||||
elseif event.etype == 'Delete'
|
||||
then
|
||||
if config.delete ~= true
|
||||
and config.delete ~= 'running'
|
||||
then
|
||||
inlet.discardEvent(event)
|
||||
return
|
||||
@ -100,38 +92,33 @@ direct.action = function(inlet)
|
||||
local tp = event.targetPath
|
||||
|
||||
-- extra security check
|
||||
if tp == '' or tp == '/' or not tp then
|
||||
error('Refusing to erase your harddisk!')
|
||||
if tp == '' or tp == '/' or not tp
|
||||
then
|
||||
error( 'Refusing to erase your harddisk!' )
|
||||
end
|
||||
|
||||
spawn(event, '/bin/rm', '-rf', '--', tp)
|
||||
|
||||
elseif event.etype == 'Move' then
|
||||
elseif event.etype == 'Move'
|
||||
then
|
||||
local tp = event.targetPath
|
||||
|
||||
-- extra security check
|
||||
if tp == '' or tp == '/' or not tp then
|
||||
error('Refusing to erase your harddisk!')
|
||||
if tp == '' or tp == '/' or not tp
|
||||
then
|
||||
error( 'Refusing to erase your harddisk!' )
|
||||
end
|
||||
|
||||
local command = '/bin/mv -- "$1" "$2" || /bin/rm -rf -- "$1"'
|
||||
|
||||
if
|
||||
config.delete ~= true and
|
||||
config.delete ~= 'running'
|
||||
if config.delete ~= true
|
||||
and config.delete ~= 'running'
|
||||
then
|
||||
command = '/bin/mv -- "$1" "$2"'
|
||||
end
|
||||
|
||||
spawnShell(
|
||||
event,
|
||||
command,
|
||||
event.targetPath,
|
||||
event2.targetPath
|
||||
)
|
||||
|
||||
spawnShell( event, command, event.targetPath, event2.targetPath )
|
||||
else
|
||||
log('Warn', 'ignored an event of type "',event.etype, '"')
|
||||
log( 'Warn', 'ignored an event of type "',event.etype, '"' )
|
||||
inlet.discardEvent(event)
|
||||
end
|
||||
end
|
||||
@ -139,30 +126,37 @@ end
|
||||
--
|
||||
-- Called when collecting a finished child process
|
||||
--
|
||||
direct.collect = function(agent, exitcode)
|
||||
|
||||
direct.collect = function
|
||||
(
|
||||
agent,
|
||||
exitcode
|
||||
)
|
||||
local config = agent.config
|
||||
|
||||
if not agent.isList and agent.etype == 'Init' then
|
||||
if not agent.isList and agent.etype == 'Init'
|
||||
then
|
||||
local rc = config.rsyncExitCodes[exitcode]
|
||||
if rc == 'ok' then
|
||||
log('Normal', 'Startup of "',agent.source,'" finished: ', exitcode)
|
||||
if rc == 'ok'
|
||||
then
|
||||
log( 'Normal', 'Startup of "',agent.source,'" finished: ', exitcode )
|
||||
elseif rc == 'again'
|
||||
then
|
||||
if settings( 'insist' )
|
||||
then
|
||||
log('Normal', 'Retrying startup of "',agent.source,'": ', exitcode)
|
||||
log( 'Normal', 'Retrying startup of "',agent.source,'": ', exitcode )
|
||||
else
|
||||
log('Error', 'Temporary or permanent failure on startup of "',
|
||||
agent.source, '". Terminating since "insist" is not set.');
|
||||
terminate(-1) -- ERRNO
|
||||
terminate( -1 )
|
||||
end
|
||||
elseif rc == 'die' then
|
||||
log('Error', 'Failure on startup of "',agent.source,'": ', exitcode)
|
||||
elseif rc == 'die'
|
||||
then
|
||||
log( 'Error', 'Failure on startup of "',agent.source,'": ', exitcode )
|
||||
else
|
||||
log('Error', 'Unknown exitcode on startup of "', agent.source,': "',exitcode)
|
||||
log( 'Error', 'Unknown exitcode on startup of "', agent.source,': "',exitcode )
|
||||
rc = 'die'
|
||||
end
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
@ -180,8 +174,11 @@ direct.init = default.rsync.init
|
||||
--
|
||||
-- Checks the configuration.
|
||||
--
|
||||
direct.prepare = function( config, level )
|
||||
|
||||
direct.prepare = function
|
||||
(
|
||||
config,
|
||||
level
|
||||
)
|
||||
default.rsync.prepare( config, level + 1 )
|
||||
|
||||
end
|
||||
@ -212,3 +209,4 @@ direct.delete = true
|
||||
-- than speed up.
|
||||
|
||||
direct.maxProcesses = 1
|
||||
|
15
distclean.sh
15
distclean.sh
@ -1,3 +1,16 @@
|
||||
#!/bin/sh
|
||||
# removes all stuff generated by cmake / make
|
||||
rm -rf AdditionalInfo.txt config.h Makefile build/ CMakeCache.txt CMakeFiles/ cmake_install.cmake install_manifest.txt luacode.c *.o *.out lsyncd
|
||||
rm -rf build/ CMakeFiles/
|
||||
|
||||
rm -f \
|
||||
AdditionalInfo.txt \
|
||||
config.h \
|
||||
Makefile \
|
||||
CMakeCache.txt \
|
||||
cmake_install.cmake \
|
||||
install_manifest.txt \
|
||||
luacode.c \
|
||||
*.o \
|
||||
*.out \
|
||||
core/*.o \
|
||||
lsyncd
|
||||
|
Loading…
Reference in New Issue
Block a user