testmachine can be reused

code slightly cleaned
This commit is contained in:
boyska 2016-02-09 20:20:37 -05:00
parent 4f746575f4
commit a12a27ef65

View file

@ -12,7 +12,16 @@ sourcemachine=jessie-amd64-base
# questa macchina ha alcune cose di base installate/configurate
# come Apache, PHP, eccetera
intermediate=wwwd8-base
if [[ $# -eq 0 ]]; then
testmachine=wwwd8-test-$(date +%y%m%d%H%M%S)
elif [[ $# -eq 1 ]]; then
testmachine=$1
shift 1
else
echo "Usage error" >&2
exit 2
fi
conf="$(dirname $0)/../config.sh"
[[ -f "$conf" ]] && . "$conf"
@ -29,12 +38,16 @@ inm() {
systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${machine}" "$@"
}
# intermediate creation END {{{1
if ! machineexists "$intermediate"; then
if ! machineexists "$sourcemachine"; then
sourcecreate() {
progress "Creating source machine"
debootstrap "/var/lib/machines/${sourcemachine}"
ok "Source machine created ($sourcemachine)"
}
intermcreate() {
if ! machineexists "$intermediate"; then
if ! machineexists "$sourcemachine"; then
sourcecreate
fi
machinectl clone "${sourcemachine}" "${intermediate}"
fi
@ -68,15 +81,20 @@ if ! inm $intermediate /usr/bin/test -x /root/.composer/vendor/bin/drush; then
error Cannot install drush
exit 1
else
ln -sf /root/.composer/vendor/bin/drush /usr/bin/drush
inm ${intermediate} /bin/ln -sf /root/.composer/vendor/bin/drush /usr/bin/drush
ok "Drush installed"
fi
ok "Intermediate machine $intermediate set up"
# intermediate creation END }}}1
}
testcreate() {
if ! machineexists "${testmachine}"; then
intermcreate
machinectl clone "${intermediate}" "${testmachine}"
fi
}
testcreate
progress "deploying on ${testmachine}"
systemd-nspawn -D "/var/lib/machines/${testmachine}" --bind-ro="$(readlink -f $(dirname $0)/../):/mig" /mig/deploy/deploy.sh
ok "all done"
# vim: set fdm=marker: