Add a script to fix interfaces issue with Proxmox
Proxmox don't parse interfaces.d. See : https://forum.proxmox.com/threads/anyway-to-support-interfaces-d.34739/
This commit is contained in:
parent
bab4ea547e
commit
a26d42d904
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Purpose : {{{
|
||||||
|
# Proxmox only reads /etc/network/interfaces from a while
|
||||||
|
# See : https://forum.proxmox.com/threads/anyway-to-support-interfaces-d.34739/
|
||||||
|
# So any bridge,… in the subdirectory /etc/network/interfaces.d won't be
|
||||||
|
# available from webgui to manage KVM/LXC's network device.
|
||||||
|
# }}}
|
||||||
|
# This script will try to fix this waiting for a Proxmox's fix. {{{
|
||||||
|
# Check if /etc/network/interfaces.d contains file(s)
|
||||||
|
# Create a temp interfaces file
|
||||||
|
# Add some basic/header informations to the temp file
|
||||||
|
# Cat the content of interfaces.d files to the temp file
|
||||||
|
# Replace default interfaces file with the temp one
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
interfaces_dir="/etc/network/interfaces.d"
|
||||||
|
interfaces_temp="/etc/network/interfaces.temp.script"
|
||||||
|
|
||||||
|
# Test if interfaces.d is empty
|
||||||
|
if [ -z "$(ls -A ${interfaces_dir})" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create temp file
|
||||||
|
rm -f -- "${interfaces_temp}"
|
||||||
|
touch -- "${interfaces_temp}"
|
||||||
|
|
||||||
|
# Header informations
|
||||||
|
printf '%b' "# This file describes the network interfaces available on your system
|
||||||
|
# and how to activate them. For more information, see interfaces(5).
|
||||||
|
" >> "${interfaces_temp}"
|
||||||
|
|
||||||
|
# Loopback informations if not present in interfaces.d
|
||||||
|
grep -q -R "iface lo" "${interfaces_dir}" || printf '%b' "
|
||||||
|
# The loopback network interface
|
||||||
|
auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
" >> "${interfaces_temp}"
|
||||||
|
|
||||||
|
# Cat the content of interfaces.d to temp file (POSIX way)
|
||||||
|
find "${interfaces_dir}" -type f -exec cat {} >> "${interfaces_temp}" \;
|
||||||
|
|
||||||
|
# Define it a new interfaces file
|
||||||
|
mv -- "${interfaces_temp}" /etc/network/interfaces
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue