Release new version 0.76
[grml-debootstrap.git] / packer / debian64_provision.sh
index 8d1920e..c7eed1f 100644 (file)
@@ -100,7 +100,7 @@ vagrant_setup() {
   chroot ${TARGET} apt-get -y install sudo
 
   echo "* Adding Vagrant user"
-  chroot ${TARGET} useradd -d /home/vagrant -m -u 1000 vagrant
+  chroot ${TARGET} useradd -d /home/vagrant -m -u 1000 vagrant -s /bin/bash
 
   echo "* Installing Vagrant ssh key"
   mkdir -m 0700 -p ${TARGET}/home/vagrant/.ssh
@@ -184,11 +184,13 @@ EOF
     echo "** Using grml-debootstrap from Git repository"
     git clone git://git.grml.org/grml-debootstrap.git
     cd grml-debootstrap
-    GRML_DEBOOTSTRAP="$(pwd)/grml-debootstrap"
+    GRML_DEBOOTSTRAP="CONFFILES=$(pwd) $(pwd)/grml-debootstrap"
   elif [ "$GRML_DEBOOTSTRAP_VERSION" = "local" ] ; then
     echo "** GRML_DEBOOTSTRAP_VERSION is set to '$GRML_DEBOOTSTRAP_VERSION'"
-    echo "** Using /tmp/grml-debootstrap derived from local system as grml-deboostrap script"
-    GRML_DEBOOTSTRAP="bash /tmp/grml-debootstrap"
+    echo "** Using /tmp/grml-debootstrap derived from local system"
+    cd /tmp/grml-debootstrap
+    export CONFFILES=$(pwd)/etc/debootstrap
+    GRML_DEBOOTSTRAP="bash $(pwd)/usr/sbin/grml-debootstrap"
   elif [ "$GRML_DEBOOTSTRAP_VERSION" = "iso" ] ; then
     echo "** GRML_DEBOOTSTRAP_VERSION is set to '$GRML_DEBOOTSTRAP_VERSION'"
     echo "** Using grml-debootstrap as provided on ISO"
@@ -223,6 +225,29 @@ grml_debootstrap_execution() {
   $GRML_DEBOOTSTRAP --hostname "${DEBIAN_VERSION}" --release "${DEBIAN_VERSION}" --target "${INSTALL_TARGET}" --grub "${GRUB_TARGET}" --password grml --force $GRML_DEB_OPTIONS 2>&1 | tee -a /tmp/grml-debootstrap.log
 }
 
+apply_nic_workaround() {
+  # release specific stuff
+  case "$DEBIAN_VERSION" in
+    stretch|buster|bullseye|unstable|sid)
+      ;;
+    *)
+      echo "* Debian $DEBIAN_VERSION doesn't require NIC workaround"
+      return 0
+      ;;
+  esac
+
+  if ! mountpoint "${TARGET}" &>/dev/null ; then
+    echo "* Mounting target system"
+    mount "${INSTALL_TARGET}" "${TARGET}"
+  fi
+
+  echo "* Disabling predictable network interface names for Debian $DEBIAN_VERSION"
+  ln -s /dev/null "${TARGET}/etc/udev/rules.d/80-net-setup-link.rules"
+
+  echo "* Rebuilding initramfs to include udev configuration change"
+  chroot "${TARGET}" update-initramfs -u -k all
+}
+
 log_system_information() {
   if ! mountpoint "${TARGET}" &>/dev/null ; then
     echo "* Mounting target system"
@@ -288,6 +313,7 @@ grml_debootstrap_setup
 grml_debootstrap_execution
 virtualbox_setup
 vagrant_setup
+apply_nic_workaround
 log_system_information
 clean_apt_files
 automated_tests