develop csync container

This commit is contained in:
2016-06-06 21:03:58 +01:00
parent 28e6361194
commit a81bdbf983
9 changed files with 75 additions and 48 deletions

View File

@@ -1,11 +1,18 @@
#!/bin/bash
set -e
# Config
HOST_DIR=`dirname $CSYNC_CONFIG`
CONTAINER_DIR=/usr/local/etc
if [ ! -e $HOST_DIR/csync2.pem ]; then
mkdir -p $HOST_DIR
csync2 -k $HOST_DIR/csync2.pem
cp -f $CONTAINER_DIR/csync2* $HOST_DIR/
fi
rm -r $CONTAINER_DIR
ln -sf $HOST_DIR/ $CONTAINER_DIR
cp -f $HOST_DIR/csync2_$HOSTNAME.cfg $HOST_DIR/csync2.cfg
# Database
CONTAINER_DIR=/usr/local/var/lib/csync2
rm -r $CONTAINER_DIR
ln -sf $CSYNC_DATABASE/ $CONTAINER_DIR

View File

@@ -70,7 +70,7 @@ initSync = {
error("Missing 'syncid' parameter.", 4)
end
local c = "csync2_" .. config.syncid .. ".cfg"
local f, err = io.open("$CSYNC_CONFIG_DIR" .. c, "r")
local f, err = io.open("$CSYNC_CONFIG_DIR/" .. c, "r")
if not f then
error("Invalid 'syncid' parameter: " .. err, 4)
end
@@ -78,11 +78,13 @@ initSync = {
end
}
local sources = {
-- change the node1 value with respective host
-- ["/home/website/public_html"] = "node1"
-- ["/host/srv/data"] = "default"
}
for key, value in pairs(sources) do
sync {initSync, source=key, syncid=value}
end
EOF
fi
if [ ! -e $LSYNC_LOG ]; then
mkdir -p `dirname $LSYNC_LOG`
fi