Browse Source

Centralise network interface checks

master
Luke Murphy 5 years ago
parent
commit
3fb57a9b57
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 49
      bibliotecha.sh

49
bibliotecha.sh

@ -144,13 +144,12 @@ function stop_networking_services {
systemctl stop ${services}
}
function configure_network_interfaces {
echo "Configuring networking interfaces ..."
function ensure_predictable_network_interfaces {
echo "Ensuring predictable networking interfaces ..."
# shellcheck disable=SC2010
# shellcheck disable=SC2155
ethernet_interface=$(ls /sys/class/net/ | grep en)
local ethernet_filename="/etc/network/interfaces.d/${ethernet_interface}"
local ethernet_interface=$(ls /sys/class/net/ | grep en)
if [[ -z "${ethernet_interface}" ]]; then
echo ""
@ -161,14 +160,9 @@ function configure_network_interfaces {
exit 1
fi
{ echo "auto eth0";
echo "allow-hotplug ${ethernet_interface}";
echo "iface ${ethernet_interface} inet dhcp"; } > "${ethernet_filename}"
# shellcheck disable=SC2010
# shellcheck disable=SC2155
local wireless_interface=$(ls /sys/class/net/ | grep wl)
local wireless_filename="/etc/network/interfaces.d/${wireless_interface}"
if [[ -z "${wireless_interface}" ]]; then
echo ""
@ -178,6 +172,24 @@ function configure_network_interfaces {
echo ""
exit 1
fi
}
function configure_network_interfaces {
echo "Configuring networking interfaces ..."
# shellcheck disable=SC2010
# shellcheck disable=SC2155
local ethernet_interface=$(ls /sys/class/net/ | grep en)
local ethernet_filename="/etc/network/interfaces.d/${ethernet_interface}"
{ echo "auto eth0";
echo "allow-hotplug ${ethernet_interface}";
echo "iface ${ethernet_interface} inet dhcp"; } > "${ethernet_filename}"
# shellcheck disable=SC2010
# shellcheck disable=SC2155
local wireless_interface=$(ls /sys/class/net/ | grep wl)
local wireless_filename="/etc/network/interfaces.d/${wireless_interface}"
{ echo "auto ${wireless_interface}";
echo "iface ${wireless_interface} inet static";
@ -193,15 +205,6 @@ function configure_dnsmasq {
local wireless_interface=$(ls /sys/class/net/ | grep wl)
local wireless_filename="/etc/dnsmasq.d/${wireless_interface}.conf"
if [[ -z "${wireless_interface}" ]]; then
echo ""
echo "Could not determine the wireless interface"
echo "Please ensure you've configure 'predictable network interfaces'"
echo "Please see https://manual.bibliotecha.info/#troubleshooting for more"
echo ""
exit 1
fi
{ echo "bogus-priv"
echo "server=/library/10.0.0.1"
echo "local=/library/"
@ -222,15 +225,6 @@ function configure_hostapd {
local wireless_interface=$(ls /sys/class/net/ | grep wl)
local hostapd_filename="/etc/hostapd/hostapd.conf"
if [[ -z "${wireless_interface}" ]]; then
echo ""
echo "Could not determine the wireless interface"
echo "Please ensure you've configure 'predictable network interfaces'"
echo "Please see https://manual.bibliotecha.info/#troubleshooting for more"
echo ""
exit 1
fi
{ echo "interface=${wireless_interface}"
echo "ssid=Bibliotecha"
echo "hw_mode=g"
@ -393,6 +387,7 @@ function run_installation {
install_networking_packages
stop_networking_services
ensure_predictable_network_interfaces
configure_network_interfaces
configure_dnsmasq
configure_hostapd

Loading…
Cancel
Save