summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-03-11 12:56:40 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-03-11 16:45:47 +0000
commit92a399e428d7efb0666ac46037bad23bf07df16b (patch)
treec41c7662c1bcae5c5f61821197de0141cf7bcd00
parentbe20e754434decec111a50401c97dd2140cbb693 (diff)
downloaddefinitions-92a399e428d7efb0666ac46037bad23bf07df16b.tar.gz
trove: Do subsitutions in /etc at deploy-time, not at first boot
This makes it easier to merge changes between /etc when doing upgrades. Lorry and Mason config goes into local-config.git, not in /etc, so this still needs to be done at first boot when we can run Gitano commands on the target. For this reason the /etc/trove-setup.sed file is still stored in the resulting system.
-rwxr-xr-xtrove.configure42
-rw-r--r--trove.morph3
2 files changed, 34 insertions, 11 deletions
diff --git a/trove.configure b/trove.configure
index 17686eb3..a1abae97 100755
--- a/trove.configure
+++ b/trove.configure
@@ -41,17 +41,13 @@ set -e
ROOT="$1"
-# The generic system that we are configuring contains a default hostname
-# which we should override. This is necessary even when upgrading because
-# baserock-system-config-sync isn't smart enough to deal.
+##########################################################################
+# Configuration in /etc, which we need to do on all deployments.
+##########################################################################
+
echo "Set hostname to $TROVE_ID"
echo "$TROVE_ID" > "$ROOT/etc/hostname"
-if [ "$UPGRADE" == "yes" ]; then
- echo "Not configuring trove-early-setup because this is an upgrade."
- exit 0
-fi
-
##########################################################################
lua_escape()
@@ -59,8 +55,9 @@ lua_escape()
echo -n "$1" | perl -pe 's/([-+\(\).%*?^$\[\]])/%$1/g'
}
-echo "Create /etc/trove-setup.sed for trove-early-setup"
-cat <<EOF > "$ROOT/etc/trove-setup.sed"
+echo "Creating /etc/trove-setup.sed"
+
+cat <<EOF > "$ROOT"/etc/trove-setup.sed
s/##TROVE_HOSTNAME##/$TROVE_ID/g
s/##MASON_HOST##/$MASON_ID/g
s/##MASON_PORT##/18755/g
@@ -75,6 +72,18 @@ EOF
##########################################################################
+echo "Performing substitutions in /etc"
+
+sed -f "$ROOT"/etc/trove-setup.sed -i \
+ "$ROOT"/etc/cgitrc \
+ "$ROOT"/etc/gitano-setup.clod \
+ "$ROOT"/etc/lorry.conf \
+ "$ROOT"/usr/share/gitano/skel/gitano-admin/*/*.lace \
+ "$ROOT"/usr/share/gitano/skel/gitano-admin/*/*.lua \
+ "$ROOT"/usr/share/gitano/skel/gitano-admin/users/*/user.conf
+
+##########################################################################
+
# trove-early-setup needs "localhost" to be defined, and there's no
# guarantee it's going to be in DNS, or that external networking is
# up when trove-early-setup runs. We work around this by creating
@@ -85,6 +94,17 @@ cat <<EOF >> "$ROOT/etc/hosts"
EOF
##########################################################################
+# Configuration of trove-early-setup
+#
+# We configure trove-early-setup so that it runs at first boot of an initial
+# deployment, to do the parts of Trove system setup that require running
+# commands from the deployed system.
+##########################################################################
+
+if [ "$UPGRADE" == "yes" ]; then
+ echo "Not configuring trove-early-setup because this is an upgrade."
+ exit 0
+fi
echo "Create /var/lib/trove-setup"
install -d -o 0 -g 0 -m 0755 "$ROOT/var/lib/trove-setup"
@@ -187,5 +207,7 @@ ExecStart=/sbin/reboot
Restart=no
EOF
+##########################################################################
+
ln -s "/etc/systemd/system/trove-early-setup.service" \
"$ROOT/etc/systemd/system/multi-user.target.wants/trove-early-setup.service"
diff --git a/trove.morph b/trove.morph
index 4c8ecd15..a259a339 100644
--- a/trove.morph
+++ b/trove.morph
@@ -150,7 +150,8 @@ chunks:
- hg-fast-export
- name: trove-setup
repo: baserock:baserock/trove-setup
- ref: master
+ ref: baserock/sam/trove-configure
+ unpetrify-ref: master
build-depends: []
- name: lorry-controller
repo: baserock:baserock/lorry-controller