
The list network interfaces used by osbash is currently a hard-coded list in distro-specific library files (e.g., lib/functions.ubuntu.sh). With Ubuntu 16.04 LTS, network interface names differ between VirtualBox and KVM as well (unless we reconfigure the operating system to use the traditional ethX naming scheme). This patch builds the list of network interfaces at run-time which should make it easier to support distros with differing network interface naming schemes. Change-Id: Id2cd684152911289821b165daf6b8fc002f42f2d
43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
# Ubuntu /etc/network/interfaces configuration
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
readonly UBUNTU_IF_FILE=/etc/network/interfaces
|
|
|
|
function config_netif {
|
|
local if_type=$1
|
|
local if_num=${2:-""}
|
|
local ip_address=${3:-""}
|
|
local template
|
|
|
|
if [ "$if_type" = "dhcp" ]; then
|
|
template="template-ubuntu-interfaces-dhcp"
|
|
elif [ "$if_type" = "manual" ]; then
|
|
template="template-ubuntu-interfaces-manual"
|
|
else
|
|
template="template-ubuntu-interfaces-static"
|
|
fi
|
|
|
|
local if_name="$(ifnum_to_ifname "$if_num")"
|
|
|
|
# Empty line before this entry
|
|
echo | sudo tee -a "$UBUNTU_IF_FILE"
|
|
|
|
sed -e "
|
|
s,%IF_NAME%,$if_name,g;
|
|
s,%IP_ADDRESS%,$ip_address,g;
|
|
" "$TEMPLATE_DIR/$template" | sudo tee -a "$UBUNTU_IF_FILE"
|
|
}
|
|
|
|
function netcfg_init {
|
|
# Configuration functions will append to this file
|
|
sudo cp -v "$TEMPLATE_DIR/template-ubuntu-interfaces-loopback" \
|
|
"$UBUNTU_IF_FILE"
|
|
}
|
|
|
|
function netcfg_show {
|
|
echo ---------- "$UBUNTU_IF_FILE"
|
|
cat "$UBUNTU_IF_FILE"
|
|
echo ---------------------------------------------------------------
|
|
}
|