Pantherina,

That is neat! It is a specific response so it should work.


<span style="color:#323232;">#!/bin/bash
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Function to set insecure DNS
</span><span style="color:#323232;">function insecure-dns() {
</span><span style="color:#323232;">  # Backup the original resolved.conf file
</span><span style="color:#323232;">  cp /etc/systemd/resolved.conf /etc/systemd/resolved.conf.bak
</span><span style="color:#323232;">
</span><span style="color:#323232;">  # Modify resolved.conf to disable custom DNS, DoT, and DNSSEC
</span><span style="color:#323232;">  sed -i 's/^DNS=.*/#DNS=/; s/^Domains=.*/#Domains=/; s/^DNSOverTLS=.*/#DNSOverTLS=/; s/^DNSSEC=.*/#DNSSEC=/' /etc/systemd/resolved.conf
</span><span style="color:#323232;">
</span><span style="color:#323232;">  # Restart systemd-resolved
</span><span style="color:#323232;">  systemctl restart systemd-resolved
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;"># Function to set secure DNS
</span><span style="color:#323232;">function secure-dns() {
</span><span style="color:#323232;">  # Restore the original resolved.conf file
</span><span style="color:#323232;">  mv /etc/systemd/resolved.conf.bak /etc/systemd/resolved.conf
</span><span style="color:#323232;">
</span><span style="color:#323232;">  # Restart systemd-resolved
</span><span style="color:#323232;">  systemctl restart systemd-resolved
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">while true; do
</span><span style="color:#323232;">  response=$(curl -sI captive.test.com | head -n 1 | cut -d' ' -f2)
</span><span style="color:#323232;">
</span><span style="color:#323232;">  if [ "$response" == "200" ]; then
</span><span style="color:#323232;">    insecure-dns
</span><span style="color:#323232;">    xdg-open captive.test.com
</span><span style="color:#323232;">    sleep 30
</span><span style="color:#323232;">    # something to wait until window is closed, otherwise spam!
</span><span style="color:#323232;">  else
</span><span style="color:#323232;">    secure-dns
</span><span style="color:#323232;">  fi
</span><span style="color:#323232;">
</span><span style="color:#323232;">  sleep 5
</span><span style="color:#323232;">done
</span>

This should work. What would be needed is to track the process of the login and only continue when the window is closed again.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • localhost
  • All magazines
  • Loading…
    Loading the web debug toolbar…
    Attempt #