diff --git a/grml-debootstrap b/grml-debootstrap index cd57ae07..393380e1 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -144,6 +144,7 @@ Configuration options: --nokernel Skip installation of default kernel images. --nointerfaces Skip installation of default network configuration. --defaultinterfaces Install default network configuration. (default) + --hostinterfaces Copy host network configuration from host to target system. --debconf 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). @@ -345,7 +346,7 @@ fi # }}} # cmdline handling {{{ -CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,defaultinterfaces,interactive,nodebootstrap,nointerfaces,nokernel,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,post-scripts:,pre-scripts:,debconf:,vm,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,efi:,arch:,insecure,verbose,help,version,force,debug,contrib,non-free,remove-configs,sshcopyid +CMDLINE_OPTS=mirror:,iso:,release:,target:,mntpoint:,debopt:,defaultinterfaces,hostinterfaces,interactive,nodebootstrap,nointerfaces,nokernel,nopackages,filesystem:,config:,confdir:,packages:,chroot-scripts:,scripts:,post-scripts:,pre-scripts:,debconf:,vm,vmfile,vmsize:,keep_src_list,hostname:,password:,nopassword,grmlrepos,backportrepos,bootappend:,grub:,efi:,arch:,insecure,verbose,help,version,force,debug,contrib,non-free,remove-configs,sshcopyid _opt_temp=$(getopt --name grml-debootstrap -o +m:i:r:t:p:c:d:vhV --long \ $CMDLINE_OPTS -- "$@") @@ -447,9 +448,12 @@ while :; do --password) # Use specified password as password for user root shift; _opt_password="$1" ;; - --defaultinterfaces) # Install a default /etc/systemd/network/80-dhcp.network file + --defaultinterfaces) # Install a default network configuration _opt_defaultinterfaces=T ;; + --hostinterfaces) # Copy host network configuration from host to target system + _opt_hostinterfaces=T + ;; --nointerfaces) # Skip installation of default network configuration. _opt_nointerfaces=T ;; @@ -560,6 +564,7 @@ done [ "$_opt_password" ] && ROOTPASSWORD=$_opt_password [ "$_opt_nopassword" ] && NOPASSWORD='yes' [ "$_opt_defaultinterfaces" ] && USE_DEFAULT_INTERFACES="true" +[ "$_opt_hostinterfaces" ] && USE_HOST_INTERFACES="true" [ "$_opt_nointerfaces" ] && NOINTERFACES="true" [ "$_opt_nokernel" ] && NOKERNEL="true" [ "$_opt_sshcopyid" ] && SSHCOPYID="true" @@ -598,6 +603,24 @@ if [ -n "$ISO" ] && [[ "$DEBOOTSTRAP" =~ mmdebstrap$ ]] ; then bailout 1 fi +if [ "$_opt_defaultinterfaces" ] && [ "$_opt_hostinterfaces" ] ; then + eerror "The options --defaultinterfaces and --hostinterfaces conflict with each other, please drop one option from your command line." + eend 1 + bailout 1 +fi + +if [ "$_opt_defaultinterfaces" ] && [ "$_opt_nointerfaces" ] ; then + eerror "The options --defaultinterfaces and --nointerfaces conflict with each other, please drop one option from your command line." + eend 1 + bailout 1 +fi + +if [ "$_opt_nointerfaces" ] && [ "$_opt_hostinterfaces" ] ; then + eerror "The options --nointerfaces and --hostinterfaces conflict with each other, please drop one option from your command line." + eend 1 + bailout 1 +fi + if [ "$DEBUG" = "true" ] ; then set -x fi @@ -1764,18 +1787,30 @@ iface ${interface} inet dhcp einfo "Not installing default network configuration as requested via --nointerfaces option" eend 0 elif [ -n "$USE_DEFAULT_INTERFACES" ] ; then - einfo "Installing default /etc/network/interfaces as requested via --defaultinterfaces options." + einfo "Installing default /etc/network/interfaces as requested via --defaultinterfaces option" mkdir -p "${MNTPOINT}/etc/network" echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces" eend $? - einfo "Installing default /etc/systemd/network/80-dhcp.network as requested via --defaultinterfaces options." + einfo "Installing default /etc/systemd/network/80-dhcp.network as requested via --defaultinterfaces option" + mkdir -p "${MNTPOINT}/etc/systemd/network" echo "$DEFAULT_SYSTEMD_NETWORKD" > "${MNTPOINT}/etc/systemd/network/80-dhcp.network" eend $? + elif [ -n "$USE_HOST_INTERFACES" ] ; then + if [ -r /etc/network/interfaces ] ; then + einfo "Copying /etc/network/interfaces from host to target system as requested via --hostinterfaces option" + mkdir -p "${MNTPOINT}/etc/network" + cp $VERBOSE /etc/network/interfaces "${MNTPOINT}/etc/network/interfaces" + elif ls /etc/systemd/network/* &>/dev/null ; then + einfo "Copy /etc/systemd/network/* from host to target system as requested via --hostinterfaces option" + mkdir -p "${MNTPOINT}/etc/systemd/network" + cp $VERBOSE /etc/systemd/network/* "${MNTPOINT}/etc/systemd/network" + fi + eend $? fi if [ -n "${SSHCOPYID}" ] ; then if ssh-add -L >/dev/null 2>&1 ; then - einfo "Use locally available public keys to authorise root login on the target system as requested via --sshcopyid option." + einfo "Use locally available public keys to authorise root login on the target system as requested via --sshcopyid option" mkdir -p "${MNTPOINT}"/root/.ssh chmod 0700 "${MNTPOINT}"/root/.ssh if ssh-add -L >> "${MNTPOINT}"/root/.ssh/authorized_keys ; then diff --git a/grml-debootstrap.8.txt b/grml-debootstrap.8.txt index 3053eae5..68a9a786 100644 --- a/grml-debootstrap.8.txt +++ b/grml-debootstrap.8.txt @@ -80,16 +80,16 @@ Options and environment variables *--debug*:: - Execute in very verbose way. Useful for debugging possible problems - with grml-debootstrap or identify what's actually executed. + Execute in very verbose way. Useful for debugging possible problems + with grml-debootstrap or identify what's actually executed. *--defaultinterfaces*:: - Install a default /etc/network/interfaces file (enabling DHCP for all local - Ethernet, WLAN and WWAN interfaces using predictable network interface names - and using eth0 as traditional interface name for backward compatibility) - instead of taking over config from host system. - This option is automatically enabled when using --vm or --vmfile. + Install a default network configuration, that is a default + /etc/network/interfaces file (enabling DHCP for the first detected Ethernet + interfaces using predictable network interface names and using eth0 as + traditional interface name for backward compatibility). + This is the default and conflicts with --hostinterfaces and --nointerfaces. *--efi* _device_:: @@ -130,6 +130,13 @@ Options and environment variables Show summary of options and exit. +*--hostinterfaces*:: + + Copy host network configuration from host to target system, copying + /etc/network/interfaces and/or /etc/systemd/network/* if they exists. + This behavior used to be the default till grml-debootstrap v0.90. + Conflicts with --defaultinterfaces and --nointerfaces. + *--hostname* _hostname_:: Use specified hostname instead of the default (being $HOSTNAME or if unset 'grml'). @@ -155,12 +162,12 @@ Options and environment variables Skip debootstrap, only do configuration to the target. - *--nointerfaces*:: Skip installation of a default network configuration. - Does not provide a default /etc/systemd/network/80-dhcp.network and + Does neither provide a default /etc/systemd/network/80-dhcp.network nor /etc/network/interfaces on the target system. + Conflicts with --defaultinterfaces and --hostinterfaces. *--nokernel*:: @@ -251,7 +258,6 @@ Options and environment variables partitioned. This allows deployment of a Virtual Machine. The options needs to be combined with the --target option. - This option automatically enables the --defaultinterfaces option. Usage example: --vm --target /dev/mapper/your-vm-disk *--vmfile*:: @@ -260,7 +266,6 @@ Options and environment variables partition/block device or directory. This allows deployment of a Virtual Machine. ('qemu-img create -f raw ...' is executed on the specified target). - This option automatically enables the --defaultinterfaces option. Usage example: --vmfile --target /mnt/sda1/qemu.img *--vmsize* _size_:: @@ -281,9 +286,8 @@ docs and /etc/debootstrap/config for further information. Networking ---------- -By default (that is, if none of the options *--nointerfaces*, -*--defaultinterfaces*, *--vmfile* or *--vm* are given) /etc/network/interfaces -will be copied from the host to the target system. +By default a default network configuration is installed, see *--defaultinterfaces*. +To change the behavior, see *--nointerfaces* and *--hostinterfaces*. Usage examples ---------------