#!/usr/bin/env bash run_directory=$(dirname $(readlink -f "$0")) source "$run_directory/variables.conf" # 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) cp /run/libreelec/resolv.conf /run/libreelec/resolv.conf.bck sed -i "$((lines - count + 1))s/^/nameserver $dns_server\n/" /run/libreelec/resolv.conf exit 0