Files
big-bear-scripts-bigbeartec…/enable-dns-service/enable_dns_service.sh
Christopher 222e6af258 🔧 refactor: Use #!/usr/bin/env bash in all shell scripts (#16)
This commit refactors all the shell scripts to use `#!/usr/bin/env bash` instead of `#!/bin/bash`. This change ensures that the scripts will run with the system's default Bash interpreter, even if it is not located at the standard `/bin/bash` path.
2024-10-23 13:32:15 -05:00

35 lines
1.0 KiB
Bash

#!/usr/bin/env bash
# This script restores the original DNS settings and re-enables systemd-resolved
# Check for root privileges
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
resolv_conf="/etc/resolv.conf"
backup_resolv_conf="/etc/resolv.conf.bak"
# Restore the original resolv.conf from backup if it exists
if [ -f "$backup_resolv_conf" ]; then
echo "Restoring the original DNS settings from backup..."
cp "$backup_resolv_conf" "$resolv_conf"
echo "Restored /etc/resolv.conf:"
cat "$resolv_conf"
else
echo "No backup found. Cannot restore the original DNS settings."
exit 1
fi
# Re-enable and start systemd-resolved if it was disabled
if systemctl is-enabled systemd-resolved.service | grep -q 'disabled'; then
echo "Re-enabling and starting systemd-resolved..."
systemctl enable systemd-resolved.service
systemctl start systemd-resolved.service
else
echo "systemd-resolved was not disabled by the script, no action needed."
fi
echo "Script reversal complete."