Copy /etc/network/interfaces from host system, unless --nointerfaces is used or targe...
authorMichael Prokop <mika@grml.org>
Wed, 16 Apr 2014 05:46:19 +0000 (07:46 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 18 Apr 2014 22:03:16 +0000 (00:03 +0200)
Thanks: Michael Renner <michael.renner@amd.co.at> for feature request and sponsoring my development time

cmdlineopts.clp
grml-debootstrap
grml-debootstrap.8.txt

index fd773e8..9c6bafa 100644 (file)
@@ -12,7 +12,7 @@
 # should be handled in the main script, where it belongs.
 ################################################################################
 
 # should be handled in the main script, where it belongs.
 ################################################################################
 
-CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,nodebootstrap,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,pre-scripts:,debconf:,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,arch:,insecure,verbose,help,version,force,debug
+CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,interactive,nodebootstrap,nointerfaces,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,pre-scripts:,debconf:,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,arch:,insecure,verbose,help,version,force,debug
 
 _opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \
     $CMDLINE_OPTS -- "$@"`
 
 _opt_temp=`getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \
     $CMDLINE_OPTS -- "$@"`
@@ -107,6 +107,9 @@ while :; do
   --password)          # Use specified password as password for user root
     shift; _opt_password="$1"
     ;;
   --password)          # Use specified password as password for user root
     shift; _opt_password="$1"
     ;;
+  --nointerfaces)      # Skip installation of /etc/network/interfaces
+    _opt_nointerfaces=T
+    ;;
   --nopassword)        # Skip password dialog
     _opt_nopassword=T
     ;;
   --nopassword)        # Skip password dialog
     _opt_nopassword=T
     ;;
index d573ca9..493ed7a 100755 (executable)
@@ -93,6 +93,9 @@ Configuration options:
                              instead of using /etc/debootstrap/packages.
       --nopackages         Skip installation of packages defined in
                              /etc/debootstrap/packages
                              instead of using /etc/debootstrap/packages.
       --nopackages         Skip installation of packages defined in
                              /etc/debootstrap/packages
+      --nointerfaces       Do not copy /etc/network/interfaces from host system
+                           to target system.
+                           (This option is automatically enabled when using --vmfile.)
       --debconf <file>     Pre-seed packages using specified pre-seed db file.
       --grmlrepos          Enable Grml's Debian repository (deb.grml.org).
       --backportrepos      Enable Debian's backports repository (backports.debian.org).
       --debconf <file>     Pre-seed packages using specified pre-seed db file.
       --grmlrepos          Enable Grml's Debian repository (deb.grml.org).
       --backportrepos      Enable Debian's backports repository (backports.debian.org).
@@ -328,6 +331,7 @@ fi
 [ "$_opt_hostname" ]            && HOSTNAME=$_opt_hostname
 [ "$_opt_password" ]            && ROOTPASSWORD=$_opt_password
 [ "$_opt_nopassword" ]          && NOPASSWORD='yes'
 [ "$_opt_hostname" ]            && HOSTNAME=$_opt_hostname
 [ "$_opt_password" ]            && ROOTPASSWORD=$_opt_password
 [ "$_opt_nopassword" ]          && NOPASSWORD='yes'
+[ "$_opt_nointerfaces" ]        && NOINTERFACES="true"
 [ "$_opt_bootappend" ]          && BOOT_APPEND=$_opt_bootappend
 [ "$_opt_grub" ]                && GRUB=$_opt_grub
 [ "$_opt_arch" ]                && ARCH=$_opt_arch
 [ "$_opt_bootappend" ]          && BOOT_APPEND=$_opt_bootappend
 [ "$_opt_grub" ]                && GRUB=$_opt_grub
 [ "$_opt_arch" ]                && ARCH=$_opt_arch
@@ -1147,6 +1151,7 @@ preparechroot() {
   [ -n "$MIRROR" ]              && echo "MIRROR=\"$MIRROR\""                           >> $CHROOT_VARIABLES
   [ -n "$MKFS" ]                && echo "MKFS=\"$MKFS\""                               >> $CHROOT_VARIABLES
   [ -n "$NOPASSWORD" ]          && echo "NOPASSWORD=\"true\""                          >> $CHROOT_VARIABLES
   [ -n "$MIRROR" ]              && echo "MIRROR=\"$MIRROR\""                           >> $CHROOT_VARIABLES
   [ -n "$MKFS" ]                && echo "MKFS=\"$MKFS\""                               >> $CHROOT_VARIABLES
   [ -n "$NOPASSWORD" ]          && echo "NOPASSWORD=\"true\""                          >> $CHROOT_VARIABLES
+  [ -n "$NOINTERFACES" ]        && echo "NOINTERFACES=\"true\""                        >> $CHROOT_VARIABLES
   [ -n "$PACKAGES" ]            && echo "PACKAGES=\"$PACKAGES\""                       >> $CHROOT_VARIABLES
   [ -n "$PRE_SCRIPTS" ]         && echo "PRE_SCRIPTS=\"$PRE_SCRIPTS\""                 >> $CHROOT_VARIABLES
   [ -n "$RECONFIGURE" ]         && echo "RECONFIGURE=\"$RECONFIGURE\""                 >> $CHROOT_VARIABLES
   [ -n "$PACKAGES" ]            && echo "PACKAGES=\"$PACKAGES\""                       >> $CHROOT_VARIABLES
   [ -n "$PRE_SCRIPTS" ]         && echo "PRE_SCRIPTS=\"$PRE_SCRIPTS\""                 >> $CHROOT_VARIABLES
   [ -n "$RECONFIGURE" ]         && echo "RECONFIGURE=\"$RECONFIGURE\""                 >> $CHROOT_VARIABLES
@@ -1224,9 +1229,16 @@ preparechroot() {
   [ -d $CONFFILES/var   ] && cp $VERBOSE -a -L $CONFFILES/var/*   $MNTPOINT/var/
 
   # copy local network setup to chroot
   [ -d $CONFFILES/var   ] && cp $VERBOSE -a -L $CONFFILES/var/*   $MNTPOINT/var/
 
   # copy local network setup to chroot
-  if [ -r /etc/network/interfaces -a ! -r "${MNTPOINT}"/etc/network/interfaces ] ; then
-     [ -d $MNTPOINT/etc/network ] || mkdir $MNTPOINT/etc/network
-     cp $VERBOSE /etc/network/interfaces $MNTPOINT/etc/network/interfaces
+  if [ -n "$NOINTERFACES" ] ; then
+    einfo "Not installing /etc/network/interfaces as requested via --nointerfaces option" ; eend 0
+  elif [ -n "$VIRTUAL" ] ; then
+    einfo "Installing into Virtual Machine, skipping installation of /etc/network/interfaces" ; eend 0
+  elif [ -r /etc/network/interfaces ] ; then
+    einfo "Copying /etc/network/interfaces from host to target system"
+    cp $VERBOSE /etc/network/interfaces $MNTPOINT/etc/network/interfaces
+    eend $?
+  else
+    ewarn "Couldn't read /etc/network/interfaces, not copying to target system" ; eend 0
   fi
 
   # install config file providing some example entries
   fi
 
   # install config file providing some example entries
index ec14eb6..727e11d 100644 (file)
@@ -132,6 +132,11 @@ Options and environment variables
 
     Skip debootstrap, only do configuration to the target.
 
 
     Skip debootstrap, only do configuration to the target.
 
+*--nointerfaces*::
+
+    Do not copy /etc/network/interfaces from host system to the target.
+    This option is automatically enabled when using --vmfile.
+
 *--nopackages*::
 
     Skip installation of packages defined in /etc/debootstrap/packages.
 *--nopackages*::
 
     Skip installation of packages defined in /etc/debootstrap/packages.