From 6b51acd540bd53d697bff8e5bdcafe038863ebc5 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 23 May 2024 18:19:06 -0700 Subject: [PATCH 1/6] fix: modify installer script * If the device is connected only via Wi-Fi, and the user wanted the installer to manage the network (for Debian < 12), halt the script. --- bin/install.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bin/install.sh b/bin/install.sh index 954ac8815..4f7da23bc 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -12,6 +12,18 @@ if [ -f .env ]; then source .env fi +RASPBIAN_VERSION=$(lsb_release -rs) +WLAN_ON=false +ETH_ON=true + +if [ -d /sys/class/net/wlan0/operstate ] && [ "$(cat /sys/class/net/wlan0/operstate)" = "up" ]; then + WLAN_ON=true +fi + +if [ -d /sys/class/net/eth0/operstate ] && [ "$(cat /sys/class/net/eth0/operstate)" = "up" ]; then + ETH_ON=true +fi + while getopts ":w:b:n:s:" arg; do case "${arg}" in w) @@ -92,6 +104,15 @@ export BRANCH="master" echo && read -p "Do you want Anthias to manage your network? This is recommended for most users because this adds features to manage your network. (Y/n)" -n 1 -r -s NETWORK && echo + if [ "$NETWORK" = 'y' ]; then + if [ "$RASPBIAN_VERSION" -lt 12 ] && [ "$WLAN_ON" = true ] && [ "$ETH_ON" = false ]; then + echo "Anthias requires a wired Ethernet connection if you want to manage your network on this version of Raspbian." + echo "Please connect your Raspberry Pi to the Internet using an Ethernet connection and try again." + echo "If you want to continue without network management, run the installer again and answer 'n' when prompted." + exit 1 + fi + fi + echo && read -p "Would you like to perform a full system upgrade as well? (y/N)" -n 1 -r -s UPGRADE && echo if [ "$UPGRADE" != 'y' ]; then EXTRA_ARGS=("--skip-tags" "system-upgrade") @@ -152,7 +173,6 @@ if [ ! -f /etc/locale.gen ]; then sudo locale-gen fi -RASPBIAN_VERSION=$(lsb_release -rs) APT_INSTALL_ARGS=( "git" "libffi-dev" From 5c0202b7fe5810fefee7a70c81ce43446830648d Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 23 May 2024 18:27:44 -0700 Subject: [PATCH 2/6] temporary: set repository and branch for testing --- bin/install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/install.sh b/bin/install.sh index 4f7da23bc..856bfb82f 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -219,6 +219,10 @@ fi sudo ${SUDO_ARGS[@]} pip install cryptography==38.0.2 sudo ${SUDO_ARGS[@]} pip install "$ANSIBLE_VERSION" +# @TODO: Remove the two lines below once the PR's ready to be merged. +export REPOSITORY='https://github.com/nicomiguelino/Anthias.git' +export BRANCH=${CUSTOM_BRANCH} + sudo -u ${USER} ${SUDO_ARGS[@]} ansible localhost \ -m git \ -a "repo=$REPOSITORY dest=/home/${USER}/screenly version=$BRANCH force=no" From 150440081f2aee58bb7b4746d927c50af269d161 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 23 May 2024 19:59:27 -0700 Subject: [PATCH 3/6] fix: halt installer if wi-fi is on for Bullseye and older and if network should be managed --- bin/install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bin/install.sh b/bin/install.sh index 856bfb82f..20b56ff1c 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -14,16 +14,12 @@ fi RASPBIAN_VERSION=$(lsb_release -rs) WLAN_ON=false -ETH_ON=true -if [ -d /sys/class/net/wlan0/operstate ] && [ "$(cat /sys/class/net/wlan0/operstate)" = "up" ]; then +# @TODO: Consider devices that uses Wi-Fi dongle. +if [ -f /sys/class/net/wlan0/operstate ] && [ "$(cat /sys/class/net/wlan0/operstate)" = "up" ]; then WLAN_ON=true fi -if [ -d /sys/class/net/eth0/operstate ] && [ "$(cat /sys/class/net/eth0/operstate)" = "up" ]; then - ETH_ON=true -fi - while getopts ":w:b:n:s:" arg; do case "${arg}" in w) @@ -105,10 +101,16 @@ export BRANCH="master" echo && read -p "Do you want Anthias to manage your network? This is recommended for most users because this adds features to manage your network. (Y/n)" -n 1 -r -s NETWORK && echo if [ "$NETWORK" = 'y' ]; then - if [ "$RASPBIAN_VERSION" -lt 12 ] && [ "$WLAN_ON" = true ] && [ "$ETH_ON" = false ]; then + if [ "$RASPBIAN_VERSION" -lt 12 ] && [ "$WLAN_ON" = true ]; then + tput setaf 9 + + echo "" echo "Anthias requires a wired Ethernet connection if you want to manage your network on this version of Raspbian." echo "Please connect your Raspberry Pi to the Internet using an Ethernet connection and try again." echo "If you want to continue without network management, run the installer again and answer 'n' when prompted." + echo "" + + tput sgr 0 exit 1 fi fi From 04010e1d9d24f8b1ce5d49583a34334a4fd47f4d Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 23 May 2024 20:05:55 -0700 Subject: [PATCH 4/6] fix: modify error message if Wi-Fi is enabled on Bullseye and older --- bin/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install.sh b/bin/install.sh index 20b56ff1c..d377d62f8 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -106,7 +106,7 @@ export BRANCH="master" echo "" echo "Anthias requires a wired Ethernet connection if you want to manage your network on this version of Raspbian." - echo "Please connect your Raspberry Pi to the Internet using an Ethernet connection and try again." + echo "Please connect your Raspberry Pi to the Internet and make sure that Wi-Fi is disabled." echo "If you want to continue without network management, run the installer again and answer 'n' when prompted." echo "" From b2ea612d38bb9c54e9491403ffa7bfafbfafa967 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Thu, 23 May 2024 21:29:50 -0700 Subject: [PATCH 5/6] fix: remove temporary snippet from the install script --- bin/install.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bin/install.sh b/bin/install.sh index d377d62f8..eeafbd616 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -221,10 +221,6 @@ fi sudo ${SUDO_ARGS[@]} pip install cryptography==38.0.2 sudo ${SUDO_ARGS[@]} pip install "$ANSIBLE_VERSION" -# @TODO: Remove the two lines below once the PR's ready to be merged. -export REPOSITORY='https://github.com/nicomiguelino/Anthias.git' -export BRANCH=${CUSTOM_BRANCH} - sudo -u ${USER} ${SUDO_ARGS[@]} ansible localhost \ -m git \ -a "repo=$REPOSITORY dest=/home/${USER}/screenly version=$BRANCH force=no" From 906394d1c7dc16846a1adf4274faf3c8fe5f35b0 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 24 May 2024 07:41:51 -0700 Subject: [PATCH 6/6] fix: change error message to use "Raspberry Pi OS" instead of "Raspbian" --- bin/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install.sh b/bin/install.sh index eeafbd616..2463fb7f4 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -105,7 +105,7 @@ export BRANCH="master" tput setaf 9 echo "" - echo "Anthias requires a wired Ethernet connection if you want to manage your network on this version of Raspbian." + echo "Anthias requires a wired Ethernet connection if you want to manage your network on this version of Raspberry Pi OS." echo "Please connect your Raspberry Pi to the Internet and make sure that Wi-Fi is disabled." echo "If you want to continue without network management, run the installer again and answer 'n' when prompted." echo ""