[Bug 270428] rc.d improve using info/warn instead of just echo
- In reply to: bugzilla-noreply_a_freebsd.org: "[Bug 270428] rc.d improve using info/warn instead of just echo"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 25 Mar 2023 20:41:17 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270428
--- 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
# 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=$( zpool import -c $cachefile -a -N 2>&1 )
+ return_value=${?}
+ info ${message}
+ [ ${return_value} -eq 0 ] && break
fi
done
}
# diff -u /root/random /etc/rc.d/random
--- /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=${harvest_mask} > /dev/null
- ${SYSCTL_N} kern.random.harvest.mask_symbolic
+ message=$( echo -n 'Setting up harvesting:' )
+ ${SYSCTL} kern.random.harvest.mask=${harvest_mask} 1> /dev/null
2> /dev/null
+ message="${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
--- /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=$( 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=0
case $1 in
static)
- message=$( static_$2 add $3 )
- info "${message}"
+ static_$2 add $3
_ret=$?
;;
options)
options_$2
;;
doall)
- message=$( static_$2 add $3 )
+ static_$2 add $3
_ret=$?
- info "${message}"
options_$2
;;
esac
@@ -135,9 +132,9 @@
_fibs=$((`${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=$( echo -n "Additional $1 routing options:" )
+ echo -n "Additional $1 routing options:"
_ropts_initdone=yes
fi
}
@@ -355,8 +352,7 @@
if checkyesno gateway_enable; then
ropts_init inet
- message="${message} gateway=YES"
-
+ echo -n ' gateway=YES'
${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
else
${SYSCTL} net.inet.ip.forwarding=0 > /dev/null
@@ -364,7 +360,7 @@
if checkyesno forward_sourceroute; then
ropts_init inet
- message="${message} do source routing=YES"
+ echo -n ' do source routing=YES'
${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
else
${SYSCTL} net.inet.ip.sourceroute=0 > /dev/null
@@ -372,7 +368,7 @@
if checkyesno accept_sourceroute; then
ropts_init inet
- message="${message} accept source routing=YES"
+ echo -n ' accept source routing=YES'
${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
else
${SYSCTL} net.inet.ip.accept_sourceroute=0 > /dev/null
@@ -380,15 +376,13 @@
if checkyesno arpproxy_all; then
ropts_init inet
- message="${message} ARP proxyall=YES"
+ echo -n ' ARP proxyall=YES'
${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
else
${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
fi
- [ -n "${_ropts_initdone}" ] && message="${message} ."
-
- info "${message}"
+ [ -n "${_ropts_initdone}" ] && echo '.'
}
options_inet6()
@@ -397,15 +391,13 @@
if checkyesno ipv6_gateway_enable; then
ropts_init inet6
- message="${message} gateway=YES"
+ echo -n ' gateway=YES'
${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
else
${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
fi
- [ -n "${_ropts_initdone}" ] && message="${message} ."
-
- info "${message}"
+ [ -n "${_ropts_initdone}" ] && echo '.'
}
load_rc_config $name
Regards,
vermaden
--
You are receiving this mail because:
You are the assignee for the bug.