From bf7f3ae694b29c70e740e72f2a74033b37995049 Mon Sep 17 00:00:00 2001 From: Orazio <22700499+orazioedoardo@users.noreply.github.com> Date: Tue, 3 May 2022 11:19:45 +0200 Subject: [PATCH] Fix static IP support on 64-bit Raspberry Pi OS. --- auto_install/install.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index f98ee4d..6d43a3f 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -129,14 +129,15 @@ main(){ fi chooseInterface - if [ "$PLAT" != "Raspbian" ]; then - avoidStaticIPv4Ubuntu - else + if checkStaticIpSupported; then getStaticIPv4Settings if [ -z "$dhcpReserv" ] || [ "$dhcpReserv" -ne 1 ]; then setStaticIPv4 fi + else + staticIpNotSupported fi + chooseUser cloneOrUpdateRepos # Install @@ -453,8 +454,8 @@ preconfigurePackages(){ fi fi - # We set static IP only on Raspbian - if [ "$PLAT" = "Raspbian" ]; then + # We set static IP only on Raspberry Pi OS + if checkStaticIpSupported; then BASE_DEPS+=(dhcpcd5) fi @@ -724,14 +725,26 @@ if [ "$pivpnenableipv6" == "1" ]; then fi } -avoidStaticIPv4Ubuntu() { +checkStaticIpSupported(){ + # Not really robust and correct, we should actually check for dhcpcd, not the distro, but works on Raspbian and Debian. + if [ "$PLAT" = "Raspbian" ]; then + return 0 + # If we are on 'Debian' but the raspi.list file is present, then we actually are on 64-bit Raspberry Pi OS. + elif [ "$PLAT" = "Debian" ] && [ -s /etc/apt/sources.list.d/raspi.list ]; then + return 0 + else + return 1 + fi +} + +staticIpNotSupported() { if [ "${runUnattended}" = 'true' ]; then - echo "::: Since we think you are not using Raspbian, we will not configure a static IP for you." + echo "::: Since we think you are not using Raspberry Pi OS, we will not configure a static IP for you." return fi # If we are in Ubuntu then they need to have previously set their network, so just use what you have. - whiptail --msgbox --backtitle "IP Information" --title "IP Information" "Since we think you are not using Raspbian, we will not configure a static IP for you. + whiptail --msgbox --backtitle "IP Information" --title "IP Information" "Since we think you are not using Raspberry Pi OS, we will not configure a static IP for you. If you are in Amazon then you can not configure a static IP anyway. Just ensure before this installer started you had set an elastic IP on your instance." ${r} ${c} }