Module Name:    src
Committed By:   kre
Date:           Mon Dec 25 08:35:07 UTC 2023

Modified Files:
        src/etc/rc.d: named

Log Message:
Clean up obsolete test(1) usage - use sh's || instead of test's obsolete -o,
and sh's && instead of test's obsolete -a.

Minor formatting cleanups, including removing unneeded \ line continuations.

The somewhat bizarre way that named_migrate() was made to work in a
subshell (which of itself is fine, and looks needed) has been made more
rational.  Because of that, the need to use local vars is no longer there,
(subshells can't affect the parent) and "local" in that func could be deleted
(but hasn't been).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/etc/rc.d/named

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/rc.d/named
diff -u src/etc/rc.d/named:1.27 src/etc/rc.d/named:1.28
--- src/etc/rc.d/named:1.27	Wed Mar 31 04:57:25 2021
+++ src/etc/rc.d/named	Mon Dec 25 08:35:07 2023
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: named,v 1.27 2021/03/31 04:57:25 christos Exp $
+# $NetBSD: named,v 1.28 2023/12/25 08:35:07 kre Exp $
 #
 
 # PROVIDE: named
@@ -19,11 +19,10 @@ extra_commands="reload"
 required_dirs="$named_chrootdir"	# if it is set, it must exist
 
 named_migrate()
-{
+(
 	local src="$1"
 	local dst="$2$1"
 	echo "Migrating $src to $dst"
-(
 	diff=false
 	cd "$src"
 	mkdir -p "$dst"
@@ -59,15 +58,14 @@ named_migrate()
 		ln -s "$dst" "$src"
 	fi
 )
-}
 
 copy_if_newer()
 {
 	local chrootdir="$1"
 	local dir="$2"
 	local file="$3"
-	if [ ! -x "${chrootdir}${dir}/${file}" -o \
-	    "${chrootdir}${dir}/${file}" -ot "${dir}/${file}" ]; then
+	if ! [ -x "${chrootdir}${dir}/${file}" ] ||
+	     [ "${chrootdir}${dir}/${file}" -ot "${dir}/${file}" ]; then
 		rm -f "${chrootdir}${dir}/${file}"
 		cp -p "${dir}/${file}" "${chrootdir}${dir}/${file}"
 	fi
@@ -75,13 +73,13 @@ copy_if_newer()
 
 named_precmd()
 {
-	if [ ! -e "/etc/rndc.key" ]; then
+	if ! [ -e "/etc/rndc.key" ]; then
 		echo "Generating rndc.key"
 		/usr/sbin/rndc-confgen -a
 	fi
 
 	if [ -z "$named_chrootdir" ]; then
-		if [ ! -d "/etc/namedb/keys" ]; then
+		if ! [ -d "/etc/namedb/keys" ]; then
 			mkdir -m 775 "/etc/namedb/keys"
 			chown named:named "/etc/namedb/keys"
 		fi
@@ -100,7 +98,7 @@ named_precmd()
 	case "$($command -v)" in
 	BIND*)	# 9 no group, named-xfer, or ndc
 		named_plugindir="/usr/libexec/named"
-		if [ ! -d "${named_chrootdir}${named_plugindir}" ]; then
+		if ! [ -d "${named_chrootdir}${named_plugindir}" ]; then
 		    mkdir -p -m 755 "${named_chrootdir}${named_plugindir}"
 		    chown root:wheel "${named_chrootdir}${named_plugindir}"
 		fi
@@ -117,32 +115,34 @@ named_precmd()
 	esac
 
 	for i in null random urandom; do
-		if [ ! -c "${named_chrootdir}/dev/$i" ]; then
+		if ! [ -c "${named_chrootdir}/dev/$i" ]; then
 			rm -f "${named_chrootdir}/dev/$i"
-			(cd /dev &&
-			    /bin/pax -rw -pe "$i" "${named_chrootdir}/dev")
+			( cd /dev &&
+			    /bin/pax -rw -pe "$i" "${named_chrootdir}/dev" )
 		fi
 	done
 
-	if [ ! -h /etc/namedb ]; then
-		named_migrate /etc/namedb ${named_chrootdir}
+	if ! [ -h /etc/namedb ]; then
+		named_migrate /etc/namedb "${named_chrootdir}"
 	fi
 
 	for i in named.conf rndc.key; do
-		if [ \( -r "/etc/$i" \) -a \( ! -h "/etc/$i" \) -a \
-		     \( ! -r "${named_chrootdir}/etc/$i" \) ]; then
+		if [ -r "/etc/$i" ] && ! [ -h "/etc/$i" ] &&
+		 ! [ -r "${named_chrootdir}/etc/$i" ]
+		then
 			mv "/etc/$i" "${named_chrootdir}/etc/$i"
 			ln -s "${named_chrootdir}/etc/$i" "/etc/$i"
 		fi
 	done
 
-	if [ \( ! -r ${named_chrootdir}/etc/named.conf \) -a \
-	    \( -r ${named_chrootdir}/etc/namedb/named.conf \) ]; then
-		ln -s namedb/named.conf ${named_chrootdir}/etc
+	if ! [ -r ${named_chrootdir}/etc/named.conf ]  &&
+	     [ -r ${named_chrootdir}/etc/namedb/named.conf ]
+	then
+		ln -s namedb/named.conf "${named_chrootdir}/etc"
 	fi
 
 	if [ -f /etc/localtime ]; then
-		cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" || \
+		cmp -s /etc/localtime "${named_chrootdir}/etc/localtime" ||
 		    cp -p /etc/localtime "${named_chrootdir}/etc/localtime"
 	fi
 

Reply via email to