Skip to content

Commit a6c4fd8

Browse files
committed
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 <awilliam@redhat.com>
1 parent be51e75 commit a6c4fd8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

start_flash.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22
bold=$(tput bold)
33
normal=$(tput sgr0)
44
. ./config.txt
5+
# whether we found systemd-resolved during setup
6+
resolved=""
57

68
setup () {
79
echo "tuya-convert $(git describe --tags)"
10+
if sudo systemctl is-active systemd-resolved.service > /dev/null 2>&1; then
11+
resolved="yes"
12+
echo "systemd-resolved is running! we must disable it."
13+
echo "name resolution will not work until this script is done."
14+
echo "if this script does not exit cleanly, you may need to run:"
15+
echo "sudo systemctl unmask systemd-resolved.service"
16+
echo "sudo systemctl start systemd-resolved.service"
17+
sudo systemctl stop systemd-resolved.service
18+
sudo systemctl mask systemd-resolved.service
19+
fi
820
pushd scripts >/dev/null || exit
921
. ./setup_checks.sh
1022
screen_minor=$(screen --version | cut -d . -f 2)
@@ -41,6 +53,11 @@ cleanup () {
4153
sudo screen -S smarthack-udp -X stuff '^C'
4254
echo "Closing AP"
4355
sudo pkill hostapd
56+
if [ -n ${resolved} ]; then
57+
echo "Re-enabling systemd-resolved..."
58+
sudo systemctl unmask systemd-resolved.service || echo "Unmasking systemd-resolved.service failed! Please clean up manually"
59+
sudo systemctl start systemd-resolved.service || echo "Restarting systemd-resolved.service failed! Please clean up manually"
60+
fi
4461
echo "Exiting..."
4562
popd >/dev/null || exit
4663
}

0 commit comments

Comments
 (0)