Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare switch from legacy network interfaces to systemd-networkd #110

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions debian/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
grml-debootstrap (0.82+nmu1) UNRELEASED; urgency=medium

Starting with this release grml-debootstrap enables systemd-networkd by
default on Debian/stretch systems.

The old default behaviour where the host /etc/network/interfaces was used to
deploy the target network configuration was dropped in favor of using the
--defaultinterfaces option where all ethernet devices are configured to use
DHCP via systemd-networkd. For legacy reasons we also provide a
/etc/network/interfaces where `eth0` is configured to use DHCP.

-- Darshaka Pathirana <[email protected]> Wed, 25 Jul 2018 11:02:01 +0200

grml-debootstrap (0.70) unstable; urgency=medium

The 'contrib' and 'non-free' repositories are no longer
Expand Down
86 changes: 56 additions & 30 deletions grml-debootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ MNTPOINT="/mnt/debootstrap.$$"
[ -n "$TIMEZONE" ] || TIMEZONE='Europe/Vienna'
[ -n "$TUNE2FS" ] || TUNE2FS='tune2fs -c0 -i0'
[ -n "$UPGRADE_SYSTEM" ] || UPGRADE_SYSTEM='yes'
[ -n "$USE_DEFAULT_INTERFACES" ] || USE_DEFAULT_INTERFACES="true"
[ -n "$VMSIZE" ] || VMSIZE="2G"
[ -n "$GRUB_INSTALL" ] || GRUB_INSTALL='yes'

Expand Down Expand Up @@ -141,11 +142,9 @@ Configuration options:
--nopackages Skip installation of packages defined in
/etc/debootstrap/packages
--nokernel Skip installation of default kernel images.
--nointerfaces Do not copy /etc/network/interfaces from host system
to target system.
(This option is automatically enabled when using --vmfile.)
--defaultinterfaces Install a default /etc/network/interfaces file (enabling
DHCP for eth0) instead of taking over config from host system.
--nointerfaces Skip installation of default network configuration.
--defaultinterfaces Install default network configuration. (default)
--hostinterfaces Copy host network configuration from host to target system.
--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).
Expand Down Expand Up @@ -347,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 -- "$@")
Expand Down Expand Up @@ -449,10 +448,13 @@ while :; do
--password) # Use specified password as password for user root
shift; _opt_password="$1"
;;
--defaultinterfaces) # Install default /etc/network/interfaces
--defaultinterfaces) # Install a default network configuration
_opt_defaultinterfaces=T
;;
--nointerfaces) # Skip installation of /etc/network/interfaces
--hostinterfaces) # Copy host network configuration from host to target system
_opt_hostinterfaces=T
;;
--nointerfaces) # Skip installation of default network configuration.
_opt_nointerfaces=T
;;
--nokernel) # Skip installation of default kernel images
Expand Down Expand Up @@ -562,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"
Expand Down Expand Up @@ -600,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
Expand Down Expand Up @@ -1713,6 +1734,16 @@ preparechroot() {
[ -d "${CONFFILES}"/var ] && cp $VERBOSE -a -L "${CONFFILES}"/var/* "${MNTPOINT}"/var/

# network setup

# systemd-networkd
DEFAULT_SYSTEMD_NETWORKD="# /etc/systemd/network/80-dhcp.network - generated by grml-debootstrap
[Match]
Name=en*
jkirk marked this conversation as resolved.
Show resolved Hide resolved

[Network]
DHCP=yes
"
# legacy network interfaces
DEFAULT_INTERFACES="# /etc/network/interfaces - generated by grml-debootstrap

# Include files from /etc/network/interfaces.d when using
Expand Down Expand Up @@ -1753,38 +1784,33 @@ iface ${interface} inet dhcp
fi

if [ -n "$NOINTERFACES" ] ; then
einfo "Not installing /etc/network/interfaces as requested via --nointerfaces option" ; eend 0
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this wrong? (Now installing the 80-dhcp.network for systemd-network and the /e/n/ for ifupdown)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. The info line could be improved to reflect the current behavior.

eend $?
elif [ -n "$VIRTUAL" ] ; then
einfo "Setting up Virtual Machine, installing default /etc/network/interfaces"
mkdir -p "${MNTPOINT}/etc/network"
echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
eend $?
elif [ -r /etc/network/interfaces ] ; then
einfo "Copying /etc/network/interfaces from host to target system"
mkdir -p "${MNTPOINT}/etc/network"
cp $VERBOSE /etc/network/interfaces "${MNTPOINT}/etc/network/interfaces"
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 $?
else
ewarn "Couldn't read /etc/network/interfaces, installing default /etc/network/interfaces"
mkdir -p "${MNTPOINT}/etc/network"
echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
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

# install config file providing some example entries
if [ -r /etc/network/interfaces.examples ] && [ ! -r "$MNTPOINT/etc/network/interfaces.examples" ] ; then
mkdir -p "${MNTPOINT}/etc/network"
cp /etc/network/interfaces.examples "$MNTPOINT/etc/network/interfaces.examples"
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
Expand Down
35 changes: 21 additions & 14 deletions grml-debootstrap.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_::

Expand Down Expand Up @@ -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').
Expand Down Expand Up @@ -157,7 +164,10 @@ Options and environment variables

*--nointerfaces*::

Do not copy /etc/network/interfaces from host system to the target.
Skip installation of a default network configuration.
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*::

Expand Down Expand Up @@ -248,16 +258,14 @@ 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*::

Set up a Virtual Machine using a regular file instead of installing to a
partition/block device or directory. This allows deployment of a Virtual
Machine. The options needs to be combined with the --target option
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_::
Expand All @@ -278,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
---------------
Expand Down