WizardKit/archlive/airootfs/usr/local/bin/connect-to-network
Alan Mason 3bf0f54b1a 2016-09: Retroactive Updates
* Display Manager
  * nodm removed due to a dbus issue
    * Hopefully if Xorg can’t be run it will default to CLI
  * XFCE is now started by .zlogin
    * Removed the "Save Session" checkbox

* Networking
  * Replaced NetworkManager with systemd-networkd
    * networkd had a 33% faster boot time than NetworkManager (-10s)
    * It also more directly prioritizes wired connections
    * NOTES: This removed the ability to easily connect to new networks
      * This is okay as the WiFi changes very infrequently
      * The WiFi settings are loaded from the UFD directly
  * Added linux-firmware to support more network devices
  * broadcom-wl wouldn't compile under i686 so it's x64 only ATM
  * Removed the udev rule forcing the dhcp delay during boot
  * Server IPs updated

* Config files and wallpapers moved to <UFD>/config

* Fixed an issue where SMART was misreporting drives as bad
  * When a drive failed SMART, subsequent drives would always report "NS"
2017-12-06 17:53:59 -08:00

58 lines
1.6 KiB
Bash

#!/bin/bash
#
## Get connected to a network
# 1. Checks if already online; skips if so
# 2. If no wired devices are present then reload kernel modules
# 3. If wireless devices are present, and we're still offline, then connect to WiFi
die () {
echo "$0:" "$@" >&2
exit 1
}
# Load settings
if [[ -f "/run/archiso/bootmnt/config/arch.conf" ]]; then
source "/run/archiso/bootmnt/config/arch.conf" || \
die "ERROR: ARCH_WK media may be damaged. Please reboot or try another UFD"
else
source "/usr/local/bin/arch.conf" || \
die "ERROR: ARCH_WK media may be damaged. Please reboot or try another UFD"
echo -n "ERROR: Settings file on ARCH_WK media missing. Using build version for now"
sleep 1s
echo -n "."
sleep 1s
echo -n "."
sleep 1s
echo "."
fi
# Init
WIFI_SSID="${WIFI_SSID}"
WIFI_PASS="${WIFI_PASS}"
# Connect to network
if ! ip a | grep -Eq '(192.168|10.[0-9]+).[0-9]+.[0-9]+'; then
# LAN
if ! ip l | grep -Eq '[0-9]+: +en'; then
## Reload the tg3/broadcom driver (known fix for some Dell systems)
echo "No wired network adapters found; reloading drivers..."
sudo modprobe -r tg3
sudo modprobe broadcom
sudo modprobe tg3
sleep 5s
fi
# WiFi
if ip l | grep -Eq '[0-9]+: +wl'; then
## Skip if we're already connected (i.e. the code above worked)
if ! ip a | grep -Eq '(192.168|10.[0-9]+).[0-9]+.[0-9]+'; then
echo "Attempting to connect to ${WIFI_SSID}..."
netctl start wireless
sleep 5s
fi
fi
fi
# Done
exit 0