testmachine can be reused
code slightly cleaned
This commit is contained in:
parent
4f746575f4
commit
a12a27ef65
1 changed files with 58 additions and 40 deletions
|
@ -12,7 +12,16 @@ sourcemachine=jessie-amd64-base
|
||||||
# questa macchina ha alcune cose di base installate/configurate
|
# questa macchina ha alcune cose di base installate/configurate
|
||||||
# come Apache, PHP, eccetera
|
# come Apache, PHP, eccetera
|
||||||
intermediate=wwwd8-base
|
intermediate=wwwd8-base
|
||||||
testmachine=wwwd8-test-$(date +%y%m%d%H%M%S)
|
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"
|
conf="$(dirname $0)/../config.sh"
|
||||||
[[ -f "$conf" ]] && . "$conf"
|
[[ -f "$conf" ]] && . "$conf"
|
||||||
|
@ -29,54 +38,63 @@ inm() {
|
||||||
systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${machine}" "$@"
|
systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${machine}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# intermediate creation END {{{1
|
sourcecreate() {
|
||||||
if ! machineexists "$intermediate"; then
|
progress "Creating source machine"
|
||||||
if ! machineexists "$sourcemachine"; then
|
debootstrap "/var/lib/machines/${sourcemachine}"
|
||||||
progress "Creating source machine"
|
ok "Source machine created ($sourcemachine)"
|
||||||
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
|
fi
|
||||||
machinectl clone "${sourcemachine}" "${intermediate}"
|
progress "Setting up intermediate machine $intermediate"
|
||||||
fi
|
cat <<EOF > /var/lib/machines/${intermediate}/etc/gitconfig
|
||||||
progress "Setting up intermediate machine $intermediate"
|
|
||||||
cat <<EOF > /var/lib/machines/${intermediate}/etc/gitconfig
|
|
||||||
[transfer]
|
[transfer]
|
||||||
fsckobjects = true
|
fsckobjects = true
|
||||||
[fetch]
|
[fetch]
|
||||||
fsckobjects = true
|
fsckobjects = true
|
||||||
[receive]
|
[receive]
|
||||||
fsckObjects = true
|
fsckObjects = true
|
||||||
EOF
|
EOF
|
||||||
cat <<EOF > /var/lib/machines/${intermediate}/etc/apt/apt.conf.d/default.conf
|
cat <<EOF > /var/lib/machines/${intermediate}/etc/apt/apt.conf.d/default.conf
|
||||||
APT::Default-Release "jessie";
|
APT::Default-Release "jessie";
|
||||||
EOF
|
EOF
|
||||||
if [[ ! -f /var/lib/machines/${intermediate}/etc/apt/sources.list.d/stretch.list ]]; then
|
if [[ ! -f /var/lib/machines/${intermediate}/etc/apt/sources.list.d/stretch.list ]]; then
|
||||||
cat <<EOF > /var/lib/machines/${intermediate}/etc/apt/sources.list.d/stretch.list
|
cat <<EOF > /var/lib/machines/${intermediate}/etc/apt/sources.list.d/stretch.list
|
||||||
deb http://ftp.debian.org/debian stretch main
|
deb http://ftp.debian.org/debian stretch main
|
||||||
EOF
|
EOF
|
||||||
inm $intermediate apt-get update
|
inm $intermediate apt-get update
|
||||||
fi
|
fi
|
||||||
# those are idempotent, so...
|
# those are idempotent, so...
|
||||||
inm $intermediate /usr/bin/apt-get -y install apache2 libapache2-mod-php5 php5-gd mariadb-server git
|
inm $intermediate /usr/bin/apt-get -y install apache2 libapache2-mod-php5 php5-gd mariadb-server git
|
||||||
inm $intermediate /usr/bin/apt-get -y install -t stretch composer
|
inm $intermediate /usr/bin/apt-get -y install -t stretch composer
|
||||||
inm $intermediate /usr/sbin/a2enmod rewrite
|
inm $intermediate /usr/sbin/a2enmod rewrite
|
||||||
inm $intermediate /usr/sbin/a2enmod php5
|
inm $intermediate /usr/sbin/a2enmod php5
|
||||||
inm $intermediate /bin/mkdir -p /mig
|
inm $intermediate /bin/mkdir -p /mig
|
||||||
progress "Installation of Drush"
|
progress "Installation of Drush"
|
||||||
inm $intermediate /usr/bin/composer global require drush/drush:8.0.3
|
inm $intermediate /usr/bin/composer global require drush/drush:8.0.3
|
||||||
if ! inm $intermediate /usr/bin/test -x /root/.composer/vendor/bin/drush; then
|
if ! inm $intermediate /usr/bin/test -x /root/.composer/vendor/bin/drush; then
|
||||||
error Cannot install drush
|
error Cannot install drush
|
||||||
exit 1
|
exit 1
|
||||||
else
|
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"
|
ok "Drush installed"
|
||||||
fi
|
fi
|
||||||
ok "Intermediate machine $intermediate set up"
|
ok "Intermediate machine $intermediate set up"
|
||||||
# intermediate creation END }}}1
|
}
|
||||||
|
|
||||||
machinectl clone "${intermediate}" "${testmachine}"
|
testcreate() {
|
||||||
|
if ! machineexists "${testmachine}"; then
|
||||||
|
intermcreate
|
||||||
|
machinectl clone "${intermediate}" "${testmachine}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testcreate
|
||||||
progress "deploying on ${testmachine}"
|
progress "deploying on ${testmachine}"
|
||||||
systemd-nspawn -D "/var/lib/machines/${testmachine}" --bind-ro="$(readlink -f $(dirname $0)/../):/mig" /mig/deploy/deploy.sh
|
systemd-nspawn -D "/var/lib/machines/${testmachine}" --bind-ro="$(readlink -f $(dirname $0)/../):/mig" /mig/deploy/deploy.sh
|
||||||
ok "all done"
|
ok "all done"
|
||||||
|
|
||||||
# vim: set fdm=marker:
|
|
||||||
|
|
Loading…
Reference in a new issue