-
-
Notifications
You must be signed in to change notification settings - Fork 33
Prepare switch from legacy network interfaces to systemd-networkd #110
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
base: master
Are you sure you want to change the base?
Changes from all commits
e56284b
4e1cd1c
3a8e642
3289386
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
|
||
|
|
@@ -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). | ||
|
|
@@ -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 -- "$@") | ||
|
|
@@ -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 | ||
|
|
@@ -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" | ||
|
|
@@ -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 | ||
|
|
@@ -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* | ||
|
|
||
| [Network] | ||
| DHCP=yes | ||
| " | ||
| # legacy network interfaces | ||
| DEFAULT_INTERFACES="# /etc/network/interfaces - generated by grml-debootstrap | ||
|
|
||
| # Include files from /etc/network/interfaces.d when using | ||
|
|
@@ -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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.