libreelec-conf/set-resolv-conf.sh

21 lines
532 B
Bash
Raw Normal View History

2023-05-29 19:51:46 +02:00
#!/usr/bin/env bash
2023-06-03 19:20:22 +02:00
# TODO review entirely:
# * use DNS variable to set the first nameserver line
# * add an "ExecStop" to service, and a script to remove that first line
2023-05-29 19:51:46 +02:00
# count lines in resolv.conf
lines=$(cat /run/libreelec/resolv.conf | wc -l)
# count number of 'nameserver' entries
count=$(grep -c 'nameserver' /run/libreelec/resolv.conf)
# move last entry to top
i=$((0))
while [ $((count)) -gt 1 ]; do
sed -i -n "$((lines - i - 1)){h;n;G};p" /run/libreelec/resolv.conf
count=$((count - 1))
i=$((i + 1))
done
exit 0