30 lines
		
	
	
	
		
			782 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			782 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
NETWORKMANAGER_NETCONFIG="/var/run/netconfig/NetworkManager.netconfig"
 | 
						|
 | 
						|
dns-update() {
 | 
						|
    tmpfile=$(mktemp)
 | 
						|
    sed  --regexp-extended "s/(DNSSERVERS=)'(.*?)'/\1'$@ \2'/g" "${NETWORKMANAGER_NETCONFIG}" > "${tmpfile}"
 | 
						|
    netconfig modify -s NetworkManager -I "${tmpfile}"
 | 
						|
    rm -f "${tmpfile}"
 | 
						|
}
 | 
						|
 | 
						|
dns-restore() {
 | 
						|
    tmpfile=$(mktemp)
 | 
						|
    sed  --regexp-extended "s/$@ //g" "${NETWORKMANAGER_NETCONFIG}" > "${tmpfile}"
 | 
						|
    netconfig modify -s NetworkManager -I ${tmpfile}
 | 
						|
    rm -f ${tmpfile}
 | 
						|
}
 | 
						|
 | 
						|
dns() {
 | 
						|
    local cmdname=$1; shift
 | 
						|
    "dns-$cmdname" "$@"
 | 
						|
}
 | 
						|
 | 
						|
if declare -f "$1" >/dev/null 2>&1; then
 | 
						|
  # invoke that function, passing arguments through
 | 
						|
  "$@" # same as "$1" "$2" "$3" ... for full argument list
 | 
						|
else
 | 
						|
  echo "Function $1 not recognized" >&2
 | 
						|
  exit 1
 | 
						|
fi
 |