Make cluster_setup.sh use generated configuration file
[tridge/autocluster.git] / autocluster
index 30bce13a1e06ab8f282d4551fcc71c36e35ec693..2d8a8af7fa2b96fe2c5902622cdc3bd70acca584 100755 (executable)
@@ -1008,6 +1008,34 @@ EOF
 
 register_hook setup_base_hooks setup_network
 
+setup_base_cluster_setup_config ()
+{
+    local f
+    {
+       echo "# Generated by autocluster"
+       echo
+       # This is a bit of a hack.  Perhaps these script belong
+       # elsewhere, since they no longer have templates?
+       for f in $(find "${BASE_TEMPLATES}/all/root/scripts" -type f |
+           xargs grep -l '^#config:') ; do
+
+           b=$(basename "$f")
+           echo "# $b"
+           local vs v
+           vs=$(sed -n 's@^#config: *@@p' "$f")
+           for v in $vs ; do
+               # This could substitute the values in directly using
+               # ${!v} but then no sanity checking is done to make
+               # sure variables are set.
+               echo "${v}=\"@@${v}@@\""
+           done
+           echo
+       done
+    } | diskimage substitute_vars - "/root/scripts/cluster_setup.config"
+}
+
+register_hook setup_base_hooks setup_base_cluster_setup_config
+
 setup_timezone() {
     [ -z "$TIMEZONE" ] && {
        [ -r /etc/timezone ] && {