summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bba7c19)
Network interfaces in VM should listen to DHCP by default,
and if /etc/network/interfaces doesn't exist at all (so
takeover from host to guest isn't possible either) create
a sane default as well.
Thanks: Christian Hofstaedtler <christian@hofstaedtler.name> for suggestion + review
Thanks: Ulrich Dangel <mru@spamt.net> for review
Fixes #20
-# set up /etc/network/interfaces {{{
-interfaces() {
- if ! [ -r /etc/network/interfaces ] || ! grep -q "auto lo" /etc/network/interfaces ; then
- echo "Setting up /etc/network/interfaces"
- cat >> /etc/network/interfaces << EOF
-
-# loopback device:
-iface lo inet loopback
-auto lo
-
-# eth0:
-# iface eth0 inet dhcp
-# auto eth0
-
-EOF
- fi
-}
-# }}}
-
# set default locales {{{
default_locales() {
if [ -n "$DEFAULT_LOCALES" ] ; then
# set default locales {{{
default_locales() {
if [ -n "$DEFAULT_LOCALES" ] ; then
install_policy_rcd
for i in chrootmirror grmlrepos backportrepos kernelimg_conf \
install_policy_rcd
for i in chrootmirror grmlrepos backportrepos kernelimg_conf \
- kernel packages extrapackages reconfigure hosts interfaces \
+ kernel packages extrapackages reconfigure hosts \
default_locales timezone fstab hostname initrd grub_install passwords \
custom_scripts upgrade_system remove_apt_cache services \
remove_chrootmirror; do
default_locales timezone fstab hostname initrd grub_install passwords \
custom_scripts upgrade_system remove_apt_cache services \
remove_chrootmirror; do
[ -d $CONFFILES/usr ] && cp $VERBOSE -a -L $CONFFILES/usr/* $MNTPOINT/usr/
[ -d $CONFFILES/var ] && cp $VERBOSE -a -L $CONFFILES/var/* $MNTPOINT/var/
[ -d $CONFFILES/usr ] && cp $VERBOSE -a -L $CONFFILES/usr/* $MNTPOINT/usr/
[ -d $CONFFILES/var ] && cp $VERBOSE -a -L $CONFFILES/var/* $MNTPOINT/var/
- # copy local network setup to chroot
+ # network setup
+ DEFAULT_INTERFACES="# /etc/network/interfaces - generated by grml-debootstrap
+
+# Include files from /etc/network/interfaces.d when using
+# ifupdown v0.7.44 or newer:
+#source-directory /etc/network/interfaces.d
+
+auto lo
+iface lo inet loopback
+
+allow-hotplug eth0
+iface eth0 inet dhcp
+"
+
if [ -n "$NOINTERFACES" ] ; then
einfo "Not installing /etc/network/interfaces as requested via --nointerfaces option" ; eend 0
elif [ -n "$VIRTUAL" ] ; then
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
+ einfo "Installing into Virtual Machine, installing default /etc/network/interfaces"
+ echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
+ eend $?
elif [ -r /etc/network/interfaces ] ; then
einfo "Copying /etc/network/interfaces from host to target system"
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
+ cp $VERBOSE /etc/network/interfaces "${MNTPOINT}/etc/network/interfaces"
- ewarn "Couldn't read /etc/network/interfaces, not copying to target system" ; eend 0
+ ewarn "Couldn't read /etc/network/interfaces, installing default /etc/network/interfaces"
+ echo "$DEFAULT_INTERFACES" > "${MNTPOINT}/etc/network/interfaces"
+ eend $?
fi
# install config file providing some example entries
fi
# install config file providing some example entries