Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Mar 2023 20:41:17 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 270428] rc.d improve using info/warn instead of just echo
Message-ID:  <bug-270428-227-2sMr3b0isl@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-270428-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-270428-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D270428

--- Comment #7 from Slawomir Wojciech Wojtczak <vermaden@interia.pl> ---
Here - patches for three next services with echo->info/warn conversion:

- /etc/rc.d/zpool
- /etc/rc.d/random=20

# diff -u /root/zpool /etc/rc.d/zpool
--- /root/zpool 2023-03-25 21:10:38.312121000 +0100
+++ /etc/rc.d/zpool     2023-03-25 21:15:42.782103000 +0100
@@ -22,7 +22,10 @@

        for cachefile in /etc/zfs/zpool.cache /boot/zfs/zpool.cache; do
                if [ -r $cachefile ]; then
-                       zpool import -c $cachefile -a -N && break
+                       message=3D$( zpool import -c $cachefile -a -N 2>&1 )
+                       return_value=3D${?}
+                       info ${message}
+                       [ ${return_value} -eq 0 ] && break
                fi
        done
 }





# diff -u /root/random /etc/rc.d/random=20
--- /root/random        2023-03-25 21:16:33.459248000 +0100
+++ /etc/rc.d/random    2023-03-25 21:29:03.982450000 +0100
@@ -48,13 +48,12 @@
 {

        if [ ${harvest_mask} -gt 0 ]; then
-               echo -n 'Setting up harvesting: '
-               ${SYSCTL} kern.random.harvest.mask=3D${harvest_mask} > /dev=
/null
-               ${SYSCTL_N} kern.random.harvest.mask_symbolic
+               message=3D$( echo -n 'Setting up harvesting:' )
+               ${SYSCTL} kern.random.harvest.mask=3D${harvest_mask} 1> /de=
v/null
2> /dev/null
+               message=3D"${message} $( ${SYSCTL_N}
kern.random.harvest.mask_symbolic )"
+               info "${message}"
        fi

-       echo -n 'Feeding entropy: '
-
        if [ ! -w /dev/random ] ; then
                warn "/dev/random is not writeable"
                return 1
@@ -88,7 +87,7 @@
                ;;
        esac

-       echo '.'
+       info 'Feeding entropy: .'
 }

 random_stop()






# diff -u /etc/rc.d/routing /root/routing=20
--- /etc/rc.d/routing   2023-03-25 21:38:38.048212000 +0100
+++ /root/routing       2023-03-25 21:29:36.241501000 +0100
@@ -67,8 +67,7 @@
        ""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
                for _a in inet inet6; do
                        afexists $_a || continue
-                       message=3D$( eval static_${_a} delete $_if )
-                       info "${message}"
+                       eval static_${_a} delete $_if
                        # When $_if is specified, do not flush routes.
                        if ! [ -n "$_if" ]; then
                                eval routing_stop_${_a}
@@ -95,17 +94,15 @@
        _ret=3D0
        case $1 in
        static)
-               message=3D$( static_$2 add $3 )
-               info "${message}"
+               static_$2 add $3
                _ret=3D$?
                ;;
        options)
                options_$2
                ;;
        doall)
-               message=3D$( static_$2 add $3 )
+               static_$2 add $3
                _ret=3D$?
-               info "${message}"
                options_$2
                ;;
        esac
@@ -135,9 +132,9 @@

        _fibs=3D$((`${SYSCTL_N} net.fibs` - 1))
        if [ ${_fibs} -gt 0 ]; then
-               info "-fib 0-${_fibs}"
+               echo "-fib 0-${_fibs}"
        else
-               info ''
+               echo
        fi
 }

@@ -290,7 +287,7 @@
 ropts_init()
 {
        if [ -z "${_ropts_initdone}" ]; then
-               message=3D$( echo -n "Additional $1 routing options:" )
+               echo -n "Additional $1 routing options:"
                _ropts_initdone=3Dyes
        fi
 }
@@ -355,8 +352,7 @@

        if checkyesno gateway_enable; then
                ropts_init inet
-               message=3D"${message} gateway=3DYES"
-
+               echo -n ' gateway=3DYES'
                ${SYSCTL} net.inet.ip.forwarding=3D1 > /dev/null
        else
                ${SYSCTL} net.inet.ip.forwarding=3D0 > /dev/null
@@ -364,7 +360,7 @@

        if checkyesno forward_sourceroute; then
                ropts_init inet
-               message=3D"${message} do source routing=3DYES"
+               echo -n ' do source routing=3DYES'
                ${SYSCTL} net.inet.ip.sourceroute=3D1 > /dev/null
        else
                ${SYSCTL} net.inet.ip.sourceroute=3D0 > /dev/null
@@ -372,7 +368,7 @@

        if checkyesno accept_sourceroute; then
                ropts_init inet
-               message=3D"${message} accept source routing=3DYES"
+               echo -n ' accept source routing=3DYES'
                ${SYSCTL} net.inet.ip.accept_sourceroute=3D1 > /dev/null
        else
                ${SYSCTL} net.inet.ip.accept_sourceroute=3D0 > /dev/null
@@ -380,15 +376,13 @@

        if checkyesno arpproxy_all; then
                ropts_init inet
-               message=3D"${message} ARP proxyall=3DYES"
+               echo -n ' ARP proxyall=3DYES'
                ${SYSCTL} net.link.ether.inet.proxyall=3D1 > /dev/null
        else
                ${SYSCTL} net.link.ether.inet.proxyall=3D0 > /dev/null
        fi

-       [ -n "${_ropts_initdone}" ] && message=3D"${message} ."
-
-       info "${message}"
+       [ -n "${_ropts_initdone}" ] && echo '.'
 }

 options_inet6()
@@ -397,15 +391,13 @@

        if checkyesno ipv6_gateway_enable; then
                ropts_init inet6
-               message=3D"${message} gateway=3DYES"
+               echo -n ' gateway=3DYES'
                ${SYSCTL} net.inet6.ip6.forwarding=3D1 > /dev/null
        else
                ${SYSCTL} net.inet6.ip6.forwarding=3D0 > /dev/null
        fi

-       [ -n "${_ropts_initdone}" ] && message=3D"${message} ."
-
-       info "${message}"
+       [ -n "${_ropts_initdone}" ] && echo '.'
 }

 load_rc_config $name




Regards,
vermaden

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-270428-227-2sMr3b0isl>