Provide hostname to pre-scripts by setting up /etc/hostname
authorMichael Prokop <mika@grml.org>
Thu, 4 Jun 2015 11:38:30 +0000 (13:38 +0200)
committerMichael Prokop <mika@grml.org>
Thu, 4 Jun 2015 11:38:30 +0000 (13:38 +0200)
While at it fix coding style and quoting of execute_pre_scripts() function.

Fixes #54 @ github

grml-debootstrap

index 5e30e00..104f454 100755 (executable)
@@ -1407,17 +1407,21 @@ iface eth0 inet dhcp
 
 # execute all scripts in /etc/debootstrap/pre-scripts/ {{{
 execute_pre_scripts() {
-   # make sure we have $MNTPOINT available for our scripts
-   export MNTPOINT
-   if [ -d "$_opt_pre_scripts" ] || [ "$PRE_SCRIPTS" = 'yes' ] ; then
-      [ -d "$_opt_pre_scripts" ] && pre_scripts="$_opt_pre_scripts" || pre_scripts="$CONFFILES/pre-scripts/"
-      for script in ${pre_scripts}/* ; do
-         if [ -x "$script" ] ; then
-            einfo "Executing pre-script $script"
-            $script ; eend $?
-         fi
-      done
-   fi
+  # make sure hostname is set even before chroot-script get executed
+  echo "$HOSTNAME" > /etc/hostname
+
+  # make sure we have $MNTPOINT available for our scripts
+  export MNTPOINT
+
+  if [ -d "$_opt_pre_scripts" ] || [ "$PRE_SCRIPTS" = 'yes' ] ; then
+    [ -d "$_opt_pre_scripts" ] && pre_scripts="$_opt_pre_scripts" || pre_scripts="${CONFFILES}/pre-scripts/"
+    for script in "${pre_scripts}"/* ; do
+      if [ -x "$script" ] ; then
+        einfo "Executing pre-script $script"
+        "$script" ; eend $?
+      fi
+    done
+  fi
 }
 # }}}