This commit is contained in:
2024-02-08 15:12:58 +01:00
parent 6dd7e0084b
commit aecd070642
17 changed files with 194 additions and 490 deletions

33
dns/clear-cache.sh Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env sh
verify_commands() {
commands=("systemd-resolve" "resolvectl")
for command in "${commands[@]}"; do
which $command &> /dev/null
if [ $? -ne 0 ]; then
echo "command '$command' not found"
exit 1
fi
done
}
main() {
verify_commands
# elevate root rights if not present
if [ "$UID" -ne 0 ]; then
sudo "$0" "$@"
exit $?
else
systemd-resolve --flush-caches
resolvectl flush-caches
systemd-resolve --statistics
if [ $? -ne 0 ]; then
echo "Failed to flush cache. Maybe the systemd-resolved service is not started/enabled?"
exit 1
fi
fi
}
main $@