From 49dbcd4cd2148ed9bbc6e50b70d87ff802254bb4 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Sat, 22 Feb 2025 17:39:28 -0800 Subject: [PATCH 1/2] Add a Fedora block to install_prereq.sh This is the stuff I found I needed to make this script work on Fedora. We also install the branch of sslpsk that backs this PR: https://github.com/drbild/sslpsk/pull/28 because current upstream sslpsk does not work on Python 3.12+, and so does not work on current stable Fedora. Signed-off-by: Adam Williamson --- install_prereq.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install_prereq.sh b/install_prereq.sh index 8b45cba..b26a170 100755 --- a/install_prereq.sh +++ b/install_prereq.sh @@ -12,6 +12,11 @@ archInstall() { sudo python -m pip install --user --upgrade git+https://github.com/drbild/sslpsk.git } +fedoraInstall() { + sudo dnf -y install git iw dnsmasq hostapd screen curl python3-pip python3-wheel python3-pycryptodomex python3-paho-mqtt python3-tornado mosquitto haveged iproute iputils openssl + sudo python3 -m pip install --user --upgrade git+https://github.com/doronz88/sslpsk.git@refactor/ssl-context +} + if [[ -e /etc/os-release ]]; then source /etc/os-release else @@ -23,6 +28,8 @@ if [[ ${ID} == 'debian' ]] || [[ ${ID_LIKE-} == 'debian' ]]; then debianInstall elif [[ ${ID} == 'arch' ]] || [[ ${ID_LIKE-} == 'arch' ]]; then archInstall +elif [[ ${ID} == 'fedora' ]] || [[ ${ID_LIKE-} == 'fedora' ]]; then + fedoraInstall else if [[ -n ${ID_LIKE-} ]]; then printID="${ID}/${ID_LIKE}" From 1c2861c71a5f1eac1ed28eaaed833bb475bc3363 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Sat, 22 Feb 2025 17:43:15 -0800 Subject: [PATCH 2/2] Handle disabling and restarting systemd-resolved.service On systems that use systemd-resolved (e.g. Fedora/RHEL installs out of the box, usually), it listens on port 53, so it blocks this tool. This should handle disabling and masking it at the start of `start_flash.sh`, then unmasking and restarting it at the end. Signed-off-by: Adam Williamson --- start_flash.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/start_flash.sh b/start_flash.sh index d4916e7..a7212db 100755 --- a/start_flash.sh +++ b/start_flash.sh @@ -2,9 +2,21 @@ bold=$(tput bold) normal=$(tput sgr0) . ./config.txt +# whether we found systemd-resolved during setup +resolved="" setup () { echo "tuya-convert $(git describe --tags)" + if sudo systemctl is-active systemd-resolved.service > /dev/null 2>&1; then + resolved="yes" + echo "systemd-resolved is running! we must disable it." + echo "name resolution will not work until this script is done." + echo "if this script does not exit cleanly, you may need to run:" + echo "sudo systemctl unmask systemd-resolved.service" + echo "sudo systemctl start systemd-resolved.service" + sudo systemctl stop systemd-resolved.service + sudo systemctl mask systemd-resolved.service + fi pushd scripts >/dev/null || exit . ./setup_checks.sh screen_minor=$(screen --version | cut -d . -f 2) @@ -41,6 +53,11 @@ cleanup () { sudo screen -S smarthack-udp -X stuff '^C' echo "Closing AP" sudo pkill hostapd + if [ -n ${resolved} ]; then + echo "Re-enabling systemd-resolved..." + sudo systemctl unmask systemd-resolved.service || echo "Unmasking systemd-resolved.service failed! Please clean up manually" + sudo systemctl start systemd-resolved.service || echo "Restarting systemd-resolved.service failed! Please clean up manually" + fi echo "Exiting..." popd >/dev/null || exit }