summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Harpin <development@landsofshadow.co.uk>2014-09-10 20:05:21 +0100
committerAlex Harpin <development@landsofshadow.co.uk>2014-09-10 20:05:21 +0100
commit8d7c72275d38cfa272b56705acf145f4f83e7d05 (patch)
tree825c31c5755058fa259ce122ee062c958b41f2fe
parent2dc5f65235d321b071ed4a6811de64f8c036ba66 (diff)
downloadvyatta-cfg-system-8d7c72275d38cfa272b56705acf145f4f83e7d05.tar.gz
vyatta-cfg-system-8d7c72275d38cfa272b56705acf145f4f83e7d05.zip
vyatta-cfg-system: formatting changes for style consistency
Update scripts/vyatta-system-nameservers to have consistent identation levels and style throughout.
-rwxr-xr-xscripts/vyatta-system-nameservers107
1 files changed, 49 insertions, 58 deletions
diff --git a/scripts/vyatta-system-nameservers b/scripts/vyatta-system-nameservers
index 1df0f02c..74f2c8b6 100755
--- a/scripts/vyatta-system-nameservers
+++ b/scripts/vyatta-system-nameservers
@@ -23,71 +23,64 @@
# **** End License ****
#
-print_usage()
-{
+print_usage() {
echo "Usage:"
echo -e "\t$0 update <ip of name-server>"
echo -e "\t$0 delete <ip of name-server>"
}
-restart_dnsmasq ()
-{
- # restart dnsmasq if dns-forwarding is configured
- if cli-shell-api existsActive service dns forwarding; then
- /opt/vyatta/sbin/vyatta-dns-forwarding.pl --update-dnsforwarding >&/dev/null
- fi
+restart_dnsmasq () {
+ # restart dnsmasq if dns-forwarding is configured
+ if cli-shell-api existsActive service dns forwarding; then
+ /opt/vyatta/sbin/vyatta-dns-forwarding.pl --update-dnsforwarding >&/dev/null
+ fi
}
-restart_ntp ()
-{
- # restart ntp if ntp is configured
- if [ -f /etc/ntp.conf ] && grep -q "^server" /etc/ntp.conf; then
- /usr/sbin/invoke-rc.d ntp restart >&/dev/null
- fi
+restart_ntp () {
+ # restart ntp if ntp is configured
+ if [ -f /etc/ntp.conf ] && grep -q "^server" /etc/ntp.conf; then
+ /usr/sbin/invoke-rc.d ntp restart >&/dev/null
+ fi
}
-
-update_system_nameservers ()
-{
- nameserver=$1
- touch /etc/resolv.conf
- # if name-server already in /etc/resolv.conf then exit
- if grep -q "$nameserver\($\|[[:space:]]\)" /etc/resolv.conf; then
- exit 0
- else
- # find last instance of cli inserted nameserver
- # insert currently received nameserver immediately after that
- # this is done to keep system set nameservers priority over dhcp received nameservers
- cli_ns_array=($(awk '{if (!$3) print $2}' /etc/resolv.conf))
- cli_ns_array_len=${#cli_ns_array[*]}
- line_num=0
- if [ $cli_ns_array_len -gt 0 ]; then
- grepped_ns_line=`grep "${cli_ns_array[$cli_ns_array_len-1]}$" -n /etc/resolv.conf`
- echo ${grepped_ns_line%%:*} > /etc/resolv_tmp.conf
- line_num=`cat /etc/resolv_tmp.conf`
- fi
- head -$line_num /etc/resolv.conf > /etc/resolv_tmp.conf
- echo "nameserver $nameserver" >> /etc/resolv_tmp.conf
- total_lines=`cat /etc/resolv.conf | wc -l`
- rest_lines=`expr $total_lines - $line_num`
- tail -$rest_lines /etc/resolv.conf >> /etc/resolv_tmp.conf
- mv -f /etc/resolv_tmp.conf /etc/resolv.conf
- fi
- restart_dnsmasq
- restart_ntp
+update_system_nameservers () {
+ nameserver=$1
+ touch /etc/resolv.conf
+ # if name-server already in /etc/resolv.conf then exit
+ if grep -q "$nameserver\($\|[[:space:]]\)" /etc/resolv.conf; then
+ exit 0
+ else
+ # find last instance of cli inserted nameserver
+ # insert currently received nameserver immediately after that
+ # this is done to keep system set nameservers priority over dhcp received nameservers
+ cli_ns_array=($(awk '{if (!$3) print $2}' /etc/resolv.conf))
+ cli_ns_array_len=${#cli_ns_array[*]}
+ line_num=0
+ if [ $cli_ns_array_len -gt 0 ]; then
+ grepped_ns_line=`grep "${cli_ns_array[$cli_ns_array_len-1]}$" -n /etc/resolv.conf`
+ echo ${grepped_ns_line%%:*} > /etc/resolv_tmp.conf
+ line_num=`cat /etc/resolv_tmp.conf`
+ fi
+ head -$line_num /etc/resolv.conf > /etc/resolv_tmp.conf
+ echo "nameserver $nameserver" >> /etc/resolv_tmp.conf
+ total_lines=`cat /etc/resolv.conf | wc -l`
+ rest_lines=`expr $total_lines - $line_num`
+ tail -$rest_lines /etc/resolv.conf >> /etc/resolv_tmp.conf
+ mv -f /etc/resolv_tmp.conf /etc/resolv.conf
+ fi
+ restart_dnsmasq
+ restart_ntp
}
-delete_system_nameserver ()
-{
- nameserver=$1
- touch /etc/resolv.conf
- # remove specified nameserver
- sed -i "/$nameserver$/d" /etc/resolv.conf
- restart_dnsmasq
- restart_ntp
+delete_system_nameserver () {
+ nameserver=$1
+ touch /etc/resolv.conf
+ # remove specified nameserver
+ sed -i "/$nameserver$/d" /etc/resolv.conf
+ restart_dnsmasq
+ restart_ntp
}
-
#
# main
#
@@ -95,8 +88,8 @@ delete_system_nameserver ()
case "$1" in
update)
if [ $# -ne 2 ]; then
- print_usage
- exit 1
+ print_usage
+ exit 1
fi
update_system_nameservers $2
exit 0
@@ -104,17 +97,15 @@ case "$1" in
delete)
if [ $# -ne 2 ]; then
- print_usage
- exit 1
+ print_usage
+ exit 1
fi
delete_system_nameserver $2
exit 0
;;
-
*)
print_usage
exit 1
;;
-
esac