From 7d9c571dd9cef206e4d941e45e0252c2f85989af Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 9 Feb 2016 00:43:40 -0500 Subject: [PATCH] a quick start --- .gitignore | 3 +++ README.md | 20 ++++++++++++++++++ deploy/deploy.sh | 3 +++ nuovotema/.keepme | 0 testingtoolchain/machinectl.sh | 38 ++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 deploy/deploy.sh create mode 100644 nuovotema/.keepme create mode 100755 testingtoolchain/machinectl.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb4dfaf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config.sh +.*.sw* +*~ diff --git a/README.md b/README.md new file mode 100644 index 0000000..f18b131 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +Cosi di migrazione +======== + +Concetto +---------- + +Per rendere il tutto più riproducibile possibile, usiamo un container pulito +ogni volta. +In teoria ci sono tanti modi di farlo, quindi dentro `testingtoolchain/` +potremmo supportare vari "backend". In pratica per ora c'è solo `machinectl`. +Si potrebbe supportare il semplice chroot o un più diretto lxc. + + +Struttura file +---------------- + +* `deploy/deploy.sh` --> cosa fare dentro ad una macchina già mezza pronta +* `nuovotema` --> il nuovo tema! +* `testingtoolchain/` --> utilità per creare container e cose simili +* `config.sh` --> file opzionale con cui fare l'override di variabili diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100644 index 0000000..af5eccf --- /dev/null +++ b/deploy/deploy.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +# TODO: drush faituttecose diff --git a/nuovotema/.keepme b/nuovotema/.keepme new file mode 100644 index 0000000..e69de29 diff --git a/testingtoolchain/machinectl.sh b/testingtoolchain/machinectl.sh new file mode 100755 index 0000000..c26ef8f --- /dev/null +++ b/testingtoolchain/machinectl.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e +set -u +set -x +# questo coso assume che si usa machinectl + +# questa macchina e' una debian pulita +sourcemachine=jessie-amd64-base +# questa macchina ha alcune cose di base installate/configurate +# come Apache, PHP, eccetera +intermediate=wwwd8-base +testmachine=wwwd8-test-$(date +%y%m%d%H%M%S) + +conf="$(dirname $0)/../config.sh" +[[ -f "$conf" ]] && . "$conf" + +machineexists() { + machinectl list-images|awk '{ print $1 }'|egrep -q "^${1}\$" +} + +# intermediate creation END {{{1 +if ! machineexists "$intermediate"; then + if ! machineexists "$sourcemachine"; then + debootstrap "/var/lib/machines/${sourcemachine}" + fi + machinectl clone "${sourcemachine}" "${intermediate}" +fi +# those are idempotent, so... +systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${intermediate}" /usr/bin/apt-get -y install apache2 libapache2-mod-php5 php5-gd mariadb-server +systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${intermediate}" /usr/sbin/a2enmod rewrite +systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${intermediate}" /usr/sbin/a2enmod php5 +systemd-nspawn --setenv='DEBIAN_FRONTEND=noninteractive' -D "/var/lib/machines/${intermediate}" /bin/mkdir -p /mig +# intermediate creation END }}}1 + +machinectl clone "${intermediate}" "${testmachine}" +systemd-nspawn -D "/var/lib/machines/${testmachine}" --bind-ro="$(readlink -f $(dirname $0)/../):/mig" /mig/deploy/deploy.sh + +# vim: set fdm=marker: