Michael Dietz's picture

I tried adding the following to a patch but after I boot up the newly patched ISO image it's not changing the default network interfaces file.


echo "#The loopback network interfaces" > /etc/network/interfaces
echo "    auto lo" >> /etc/network/interfaces
echo "    iface lo inet loopback" >> /etc/network/interfaces
echo " " >> /etc/network/interfaces
echo " " >> /etc/network/interfaces
echo "#The primary network interface" >> /etc/network/interfaces
echo "    auto ${iface}" >> /etc/network/interfaces
echo "    iface ${iface} inet static" >> /etc/network/interfaces
echo "        address ${ipadd}" >> /etc/network/interfaces
echo "        netmask ${subn}" >> /etc/network/interfaces
echo "        gateway ${gatew}" >> /etc/network/interfaces
echo "        dns-nameservers" >> /etc/network/interfaces


Any suggestions? 



Jeremy Davis's picture

I assume that this is in your conf script within the patch directory? If so, is it executable? Does it have a shebang? E.g. first line like this:


If it has all those things, then I would expect it to work?!

If you're not sure whether it's executable, check it with ls. I.e.:

ls -l path/to/patch/conf

If it's executable it should look like this:

-rwxr-xr-x 1 root root 713 May  2 06:59 path/to/patch/conf

Otherwise, it may look something like this (note no 'x's):

-rw-r--r-- 1 root root 713 May  2 06:59 path/to/patch/conf

To make it executable:

chmod +x path/to/patch/conf

I was going to lead you off on a bit of a tangent and suggest using Inithooks, but we don't use that ourselves and on inspection, it looks like it needs some tweaks to make it work as intended.

You could run through the process step-by-step to check that the interfaces file has been updated like this:

# unpack the ISO
tklpatch-extract-iso path/to/iso
# apply the patch
tklpatch-apply path/to/iso.rootfs path/to/patch

# check interfaces file
cat path/to/iso.rootfs/etc/network/interfaces

# assuming that looks good
# prepare cdroot
tklpatch-prepare-cdroot path/to/iso.rootfs path/to/iso.cdroot
# generate new ISO
tklpatch-geniso path/to/iso.cdroot

Also one other (sidetrack) point is that IMO it would be better to use what is called a heredoc rather than lots of echos. It would make it make easier to read. I.e. your script could look like this instead:


cat > /etc/network/interfaces <<EOF
#The loopback network interfaces
    auto lo
    iface lo inet loopback

#The primary network interface
    auto ${iface}
    iface ${iface} inet static
        address ${ipadd}
        netmask ${subn}
        gateway ${gatew}

Although what you have should still work and there's nothing wrong with it (that I can see on face value). So my suggestion is more of an improvement for readability, rather than likely to make any material difference.

Add new comment