Remove vim comments and fix formatting a little.
[openresolv] / resolvconf.in
index 7980daaa6d1404a567b377a1d9a858f1d8b26245..d76a0e085c01e96b046de0465105eaadebabdba2 100755 (executable)
@@ -1,6 +1,5 @@
 #!/bin/sh
 #!/bin/sh
-# Copyright 2006 Gentoo Foundation
-# Copyright 2007 Roy Marples
+# Copyright 2007-2008 Roy Marples
 # All rights reserved
 
 # Redistribution and use in source and binary forms, with or without
 # All rights reserved
 
 # Redistribution and use in source and binary forms, with or without
@@ -56,7 +55,7 @@ usage() {
                    pattern
          -v [\$PATTERN]    echo NEWDOMAIN, NEWSEARCH and NEWNS variables to
                           the console
                    pattern
          -v [\$PATTERN]    echo NEWDOMAIN, NEWSEARCH and NEWNS variables to
                           the console
-         -s \$SVC \$CMD    Do \$CMD for the system service \$SVC
+         -s \$SVC \$CMD     Do \$CMD for the system service \$SVC
          -h               Show this help cruft
        EOF
        [ -z "$@" ] && exit 0
          -h               Show this help cruft
        EOF
        [ -z "$@" ] && exit 0
@@ -75,8 +74,8 @@ uniqify() {
     local result=
     while [ -n "$1" ]; do
                case " ${result} " in
     local result=
     while [ -n "$1" ]; do
                case " ${result} " in
-                       *" $1 "*) ;;
-                       *) result="${result} $1" ;;
+                       *" $1 "*);;
+                       *) result="${result} $1";;
                esac
                shift
        done
                esac
                shift
        done
@@ -105,16 +104,16 @@ if [ "x${CMD}" = "x-s" ]; then
        # If restarting check if service is running or not if we can
        if [ "x${ACTION}" = "xrestart" ]; then
                if [ -s /var/run/"${SERVICE}".pid ]; then
        # If restarting check if service is running or not if we can
        if [ "x${ACTION}" = "xrestart" ]; then
                if [ -s /var/run/"${SERVICE}".pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}".pid)
+                       kill -0 $(cat /var/run/"${SERVICE}".pid) 2>/dev/null
                elif [ -s /var/run/"${SERVICE}"/"${SERVICE}".pid ]; then
                elif [ -s /var/run/"${SERVICE}"/"${SERVICE}".pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}".pid)
+                       kill -0 $(cat /var/run/"${SERVICE}".pid) 2>/dev/null
                elif [ -s /var/run/"${SERVICE}"/pid ]; then
                elif [ -s /var/run/"${SERVICE}"/pid ]; then
-                       kill -0 $(cat /var/run/"${SERVICE}"/pid)
+                       kill -0 $(cat /var/run/"${SERVICE}"/pid) 2>/dev/null
                else
                        false
                fi
                # Service not running, so don't restart
                else
                        false
                fi
                # Service not running, so don't restart
-               [ $? != 0 ] && exit 1
+               [ $? != 0 ] && exit 0
        fi      
        if [ -x /sbin/service ]; then
                service "${SERVICE}" "${ACTION}" "$@" 
        fi      
        if [ -x /sbin/service ]; then
                service "${SERVICE}" "${ACTION}" "$@" 
@@ -141,8 +140,7 @@ if [ -n "$1" ]; then
        shift
 fi
 
        shift
 fi
 
-# -l is a Gentoo option that lists our resolv files
-# optionally for a specific interface
+# -l lists our resolv files, optionally for a specific interface
 if [ "x${CMD}" = "x-l" -o "x${CMD}" = "x-i" ]; then
        [ -d "${IFACEDIR}" ] || exit 0
        
 if [ "x${CMD}" = "x-l" -o "x${CMD}" = "x-i" ]; then
        [ -d "${IFACEDIR}" ] || exit 0
        
@@ -182,13 +180,14 @@ if [ "x${CMD}" = "x-v" ]; then
        NEWSEARCH=
        NEWNS=
        NEWDOMAIN=
        NEWSEARCH=
        NEWNS=
        NEWDOMAIN=
-       LINES="$("${argv0}" -l "${IFACE}" | sed -e "s/'/'\\\\''/g" -e "s/^/'/g" -e "s/$/'/g")"
+       LINES="$("${argv0}" -l "${IFACE}" |
+               sed -e "s/'/'\\\\''/g" -e "s/^/'/g" -e "s/$/'/g")"
        eval set -- ${LINES}
        for LINE in "$@"; do
                case "${LINE}" in
                        "nameserver "*)
                                case "${LINE#* }" in
        eval set -- ${LINES}
        for LINE in "$@"; do
                case "${LINE}" in
                        "nameserver "*)
                                case "${LINE#* }" in
-                                       127.*) continue ;;
+                                       127.*) continue;;
                                esac
                                NS="${NS}${LINE#* } "
                                ;;
                                esac
                                NS="${NS}${LINE#* } "
                                ;;
@@ -228,8 +227,10 @@ if [ "x${CMD}" = "x-v" ]; then
        for S in ${NEWSEARCH}; do
                for DN in ${NEWDOMAIN}; do
                        if [ "${S%,*}" = "${DN%,*}" ]; then
        for S in ${NEWSEARCH}; do
                for DN in ${NEWDOMAIN}; do
                        if [ "${S%,*}" = "${DN%,*}" ]; then
-                               NEWSEARCH="$(echo "${NEWSEARCH}" | sed -e "s/${S}/${DN}/g")"
-                               NEWDOMAIN="$(echo "${NEWDOMAIN}" | sed -e "s/${DN}//g")"
+                               NEWSEARCH="$(echo "${NEWSEARCH}" |
+                                       sed -e "s/${S}/${DN}/g")"
+                               NEWDOMAIN="$(echo "${NEWDOMAIN}" |
+                                       sed -e "s/${DN}//g")"
                                break
                        fi
                done
                                break
                        fi
                done
@@ -253,12 +254,12 @@ fi
 if [ "x${CMD}" = "x-a" ]; then
        for x in '/' \\ ' ' '*'; do
                case "${IFACE}" in
 if [ "x${CMD}" = "x-a" ]; then
        for x in '/' \\ ' ' '*'; do
                case "${IFACE}" in
-                       *[${x}]*) error_exit "${x} not allowed in interface name" ;;
+                       *[${x}]*) error_exit "${x} not allowed in interface name";;
                esac
        done
        for x in '.' '-' '~'; do
                case "${IFACE}" in
                esac
        done
        for x in '.' '-' '~'; do
                case "${IFACE}" in
-                       [${x}]*) error_exit "${x} not allowed at start of interface name" ;;
+                       [${x}]*) error_exit "${x} not allowed at start of interface name";;
                esac
        done
        [ "x${CMD}" = "x-a" -a -t 0 ] && error_exit "No file given via stdin"
                esac
        done
        [ "x${CMD}" = "x-a" -a -t 0 ] && error_exit "No file given via stdin"
@@ -307,5 +308,3 @@ for x in "${UPDATED}"/*; do
 done
 
 exit ${retval}
 done
 
 exit ${retval}
-
-# vim: set ts=4 :