confz

git mirror of https://ccx.te2000.cz/bzr/confz
git clone https://ccx.te2000.cz/git/confz
Log | Files | Refs

commit 048a23ebda88f01da56f5fecb40d621d9d43e369
parent 04aa20e99ac2b1a8fd5599a9150f4002560be961
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Wed, 11 Jan 2017 17:08:51 +0100

Create .confz_deployed file upon deployment
Diffstat:
Mzsh-functions/confz_vserver_init | 27++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/zsh-functions/confz_vserver_init b/zsh-functions/confz_vserver_init @@ -10,9 +10,19 @@ zmodload -F zsh/stat b:zstat # deploy filesystem image from directory, rsync or tarball confz_deployed_system_check() { checkvars path source + local existing_entries - fail_reason="${vars[path]}/bin missing" - [[ -e ${vars[path]}/bin ]] + fail_reason="${vars[path]}/.confz_deployed missing" + if [[ -e ${vars[path]}/.confz_deployed ]]; then + return 0 + else + existing_entries=( ${vars[path]}/*(DN) ) + if (($#existing_entries)); then + die "Found $#existing_entries in ${vars[path]} but no .confz_deployed" + else + return 1 + fi + fi } confz_deployed_system_do() { @@ -23,16 +33,16 @@ confz_deployed_system_do() { rsync -aAH ${vars[source]} ${vars[path]}/ || return $?;; (scp:*.(tbz|tbz2|bz2)) scp -q ${vars[source]#scp:} /dev/stdout | bzip2 -d | tar -xpC ${vars[path]} - return $[ $pipestatus[1] | $pipestatus[2] | $pipestatus[3] ];; + result=$[ $pipestatus[1] | $pipestatus[2] | $pipestatus[3] ];; (scp:*.(tgz|gz)) scp -q ${vars[source]#scp:} /dev/stdout | gzip -d | tar -xpC ${vars[path]} - return $[ $pipestatus[1] | $pipestatus[2] | $pipestatus[3] ];; + result=$[ $pipestatus[1] | $pipestatus[2] | $pipestatus[3] ];; (scp:*.xz) scp -q ${vars[source]#scp:} /dev/stdout | xz -d | tar -xpC ${vars[path]} - return $[ $pipestatus[1] | $pipestatus[2] | $pipestatus[3] ];; + result=$[ $pipestatus[1] | $pipestatus[2] | $pipestatus[3] ];; (scp:*) scp -q ${vars[source]#scp:} /dev/stdout | tar -xpC ${vars[path]} - return $[ $pipestatus[1] | $pipestatus[2] ];; + result=$[ $pipestatus[1] | $pipestatus[2] ];; (sftp:*) mkdir -p /root/.tmp || return $? (cd /root/.tmp && sftp ${vars[source]#sftp:}) || return $? @@ -42,7 +52,10 @@ confz_deployed_system_do() { (*) tar -xpC ${vars[path]} -f ${vars[source]} || return $?;; esac - return $result + if (($result)); then + return $result + fi + printf '%s\n' ${vars[source]} >${vars[path]}/.confz_deployed } # create required directories