Skip to content

Commit

Permalink
easyinstall: Dynamically detect an available network i/f, and abort i…
Browse files Browse the repository at this point in the history
…f none is found (#1193)

* Dynamically detect an available network i/f, and abort if none is found

* Network i/f fallback for headless mode

* Split piscsi installation and system service configuration
  • Loading branch information
rdmark authored Jul 31, 2023
1 parent 8089bb9 commit 3b6822d
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions easyinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ function installPiscsi() {

# install
sudo make install CONNECT_TYPE="$CONNECT_TYPE" </dev/null
}

# update launch parameters
# Update the systemd configuration for piscsi
function configurePiscsiService() {
if [[ -f $SECRET_FILE ]]; then
sudo sed -i "\@^ExecStart.*@ s@@& -F $VIRTUAL_DRIVER_PATH -P $SECRET_FILE@" "$SYSTEMD_PATH/piscsi.service"
echo "Secret token file $SECRET_FILE detected. Using it to enable back-end authentication."
Expand Down Expand Up @@ -568,9 +570,18 @@ function fetchHardDiskDrivers() {
function setupWiredNetworking() {
echo "Setting up wired network..."

LAN_INTERFACE=eth0
if [[ -z $HEADLESS ]]; then
LAN_INTERFACE=`ip -o addr show scope link | awk '{split($0, a); print $2}' | grep 'eth\|enx' | head -n 1`
else
LAN_INTERFACE="eth0"
fi

if [[ -z "$LAN_INTERFACE" ]]; then
echo "No usable wired network interfaces detected. Have you already enabled the bridge? Aborting..."
return 1
fi

echo "$LAN_INTERFACE will be configured for network forwarding with DHCP."
echo "Network interface '$LAN_INTERFACE' will be configured for network forwarding with DHCP."
echo ""
echo "WARNING: If you continue, the IP address of your Pi may change upon reboot."
echo "Please make sure you will not lose access to the Pi system."
Expand All @@ -582,7 +593,7 @@ function setupWiredNetworking() {

if [ "$REPLY" == "N" ] || [ "$REPLY" == "n" ]; then
echo "Available wired interfaces on this system:"
echo `ip -o addr show scope link | awk '{split($0, a); print $2}' | grep eth`
echo `ip -o addr show scope link | awk '{split($0, a); print $2}' | grep 'eth\|enx'`
echo "Please type the wired interface you want to use and press Enter:"
read SELECTED
LAN_INTERFACE=$SELECTED
Expand Down Expand Up @@ -635,9 +646,19 @@ function setupWirelessNetworking() {
CIDR="24"
ROUTER_IP=$NETWORK.1
ROUTING_ADDRESS=$NETWORK.0/$CIDR
WLAN_INTERFACE="wlan0"

echo "$WLAN_INTERFACE will be configured for network forwarding with static IP assignment."
if [[ -z $HEADLESS ]]; then
WLAN_INTERFACE=`ip -o addr show scope link | awk '{split($0, a); print $2}' | grep 'wlan\|wlx' | head -n 1`
else
WLAN_INTERFACE="wlan0"
fi

if [[ -z "$WLAN_INTERFACE" ]]; then
echo "No usable wireless network interfaces detected. Have you already enabled the bridge? Aborting..."
return 1
fi

echo "Network interface '$WLAN_INTERFACE' will be configured for network forwarding with static IP assignment."
echo "Configure your Macintosh or other device with the following:"
echo "IP Address (static): $IP"
echo "Router Address: $ROUTER_IP"
Expand All @@ -649,7 +670,7 @@ function setupWirelessNetworking() {

if [ "$REPLY" == "N" ] || [ "$REPLY" == "n" ]; then
echo "Available wireless interfaces on this system:"
echo `ip -o addr show scope link | awk '{split($0, a); print $2}' | grep wlan`
echo `ip -o addr show scope link | awk '{split($0, a); print $2}' | grep 'wlan\|wlx'`
echo "Please type the wireless interface you want to use and press Enter:"
read -r WLAN_INTERFACE
echo "Base IP address (ex. 10.10.20):"
Expand Down Expand Up @@ -1163,6 +1184,7 @@ function runChoice() {
compilePiscsi
backupPiscsiService
installPiscsi
configurePiscsiService
enablePiscsiService
preparePythonCommon
if [[ $(isPiscsiScreenInstalled) -eq 0 ]]; then
Expand Down Expand Up @@ -1205,6 +1227,7 @@ function runChoice() {
backupPiscsiService
preparePythonCommon
installPiscsi
configurePiscsiService
enablePiscsiService
if [[ $(isPiscsiScreenInstalled) -eq 0 ]]; then
echo "Detected piscsi oled service; will run the installation steps for the OLED monitor."
Expand Down Expand Up @@ -1382,6 +1405,7 @@ function runChoice() {
fetchHardDiskDrivers
compilePiscsi
installPiscsi
configurePiscsiService
enablePiscsiService
preparePythonCommon
cachePipPackages
Expand Down

0 comments on commit 3b6822d

Please sign in to comment.