Commit 262e6629 authored by Alain Takoudjou's avatar Alain Takoudjou

sync: exit if instance is already synced

parent 0359eddb
......@@ -20,7 +20,7 @@ eggs +=
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance-sync.cfg.jinja2.in
rendered = ${buildout:directory}/template-sync.cfg
md5sum = 3158b940beb73226f5c974ab682f8f29
md5sum = 66cc114bd3e8cf1f8181297270508373
context =
key template_logrotate_base template-logrotate-base:rendered
raw certificate_request_bin ${buildout:directory}/bin/ca-web-request
......@@ -62,7 +62,7 @@ filename = template-instance-clone.cfg.jinja2.in
[template-sync.sh]
<= template-sync-download-base
md5sum = 14db8beae2d1a027e8339d0879f32a90
md5sum = ea5a2555e5fc9d271a55ca4e809c963d
filename = template-sync.sh.in
[prepare-sync-server.sh]
......
......@@ -68,6 +68,7 @@ command-line = {{ certificate_request_bin }}
recipe = slapos.recipe.template:jinja2
template = {{ template_sync_sh }}
rendered = ${directory:bin}/instance-sync-raw
exit-complete-file = ${directory:var}/instance_sync_done
context =
key ca_certificate certificate-client-request:ca-cert
key client_base_dir buildout:directory
......@@ -78,7 +79,7 @@ context =
raw bash_executable_location {{ bash_executable_location }}
raw curl_executable_location {{ curl_executable_location }}
raw client_identity_file ${openssh-client:public-key}
raw exit_completed_file ${directory:srv}/.instance_sync_done
raw exit_completed_file ${:exit-complete-file}
raw output_log_file ${logrotate-sync-client:log}
raw python_rsync_script {{ template_python_sync }}
raw rsync_executable_location {{ rsync_executable_location }}
......
......@@ -15,6 +15,11 @@ KNOWN_HOSTS_FILE={{ ssh_known_hosts_file }}
CLONE_DIR=$BASE_DIR/var/clone-op
mkdir -p $CLONE_DIR
if [ -s "{{ exit_completed_file }}" ]; then
echo "Instance was already synced. Existing..."
exit 0
fi
if [ -s "$CLONE_DIR/ID" ]; then
UNIQUE_KEY=$(cat $CLONE_DIR/ID)
else
......@@ -27,14 +32,6 @@ READY_KEY=$UNIQUE_KEY"_ready"
DONE_KEY=$UNIQUE_KEY"_done"
INFO_KEY=$UNIQUE_KEY"_info"
# Reinitialise folder
#if [ -d "$CLONE_DIR" ]; then
# rm -rf $CLONE_DIR;
#fi
if [ -f "{{ exit_completed_file }}" ]; then
rm -f {{ exit_completed_file }};
fi
curl_client () {
# -w %{http_code}
{{ curl_executable_location }} -k -L --cert {{ client_certificate }} --key {{ client_key }} --cacert {{ ca_certificate }} $*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment