cvs commit: ports/net/quagga Makefile ports/net/quagga/files
quagga.sh.in
Doug Barton
dougb at FreeBSD.org
Mon Feb 1 21:43:50 UTC 2010
On 02/01/10 09:45, Philip M. Gollucci wrote:
> pgollucci 2010-02-01 17:45:31 UTC
>
> FreeBSD ports repository
>
> Modified files:
> net/quagga Makefile
> net/quagga/files quagga.sh.in
> Log:
> - Fix the return value of the rc.d script
>
> PR: ports/143086 http://www.FreeBSD.org/cgi/query-pr.cgi?pr=143086
> Submitted by: Emil Smolenski<am at raisa.eu.org>
> Approved by: Boris Kovalenko<boris at tagnet.ru> (maintainer)
>
> Revision Changes Path
> 1.96 +1 -1 ports/net/quagga/Makefile
> 1.16 +4 -1 ports/net/quagga/files/quagga.sh.in
>
> http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/net/quagga/Makefile.diff?&r1=1.95&r2=1.96&f=h
> http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/net/quagga/files/quagga.sh.in.diff?&r1=1.15&r2=1.16&f=h
There is a better way to accomplish what this change does which I
included in the attached patch. Most of the other changes are to bring
the script in line with customs, see
http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html
for more information. Regarding the other changes:
1. (Hopefully) improve readability for the comments
2. Add quagga_extralibs_path to the comments, some description should be
included there instead of "blah blah." :) The reason for this is that
the default empty variable assignments have been removed (they are
neither necessary nor desirable).
3. The construction "while true; do" is usually safe, but better to use
the shell internal way of saying the same thing.
4. Make $daemon in do_cmd local
I also have a sort of meta-concern about the way this script is
constructed. It would be "cleaner" to do individual scripts for each
daemon, however given the large number of daemons that are started I can
see an argument that this way is better.
The other concern I have is minor, if "-d" is the option to daemonize
the daemons then it should be moved to command_args (outside of do_cmd
should be fine) and the then-empty _flags default should be removed.
Usual caveats apply, these changes should be tested, maintainer should
submit a request for them, etc.
Doug
--
Improve the effectiveness of your Internet presence with
a domain name makeover! http://SupersetSolutions.com/
Computers are useless. They can only give you answers.
-- Pablo Picasso
-------------- next part --------------
Index: quagga.sh.in
===================================================================
RCS file: /home/pcvs/ports/net/quagga/files/quagga.sh.in,v
retrieving revision 1.16
diff -u -r1.16 quagga.sh.in
--- quagga.sh.in 1 Feb 2010 17:45:31 -0000 1.16
+++ quagga.sh.in 1 Feb 2010 21:31:40 -0000
@@ -1,38 +1,43 @@
#!/bin/sh
-#
+# $FreeBSD$
+#
# PROVIDE: quagga
# REQUIRE: netif routing
# KEYWORD: nojail
-
#
# Add the following line to /etc/rc.conf to enable quagga:
-#quagga_enable="YES"
+# quagga_enable="YES"
#
# You may also wish to use the following variables to fine-tune startup:
-# quagga_flags="-d"
-# quagga_daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"
+# quagga_flags="-d"
+# quagga_daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"
+#
# Per daemon tuning may be done with daemon_name_flags
-# zebra_flags="-dP 0"
-# bgpd_flags="-dnrP 0" and so on
+# zebra_flags="-dP 0"
+# bgpd_flags="-dnrP 0" and so on
+#
# If you want to give the routing deamons a chance to catchup before
# continueing, set quagga_wait_for to a "default" or certain prefix.
-# quagga_wait_for="default"
+# quagga_wait_for="default"
+#
+# BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
+# quagga_extralibs_path=
#
# If the quagga daemons require additional shared libraries to start,
# use the following variable to run ldconfig(8) in advance:
-#quagga_extralibs_path="/usr/local/lib ..."
+# quagga_extralibs_path="/usr/local/lib ..."
#
-. %%RC_SUBR%%
+. /etc/rc.subr
name="quagga"
rcvar=`set_rcvar`
-start_postcmd=start_postcmd
-stop_postcmd=stop_postcmd
+start_postcmd=${name}_poststart
+stop_postcmd=${name}_poststop
-start_postcmd()
+quagga_poststart()
{
# Wait only when last daemon has started.
if [ "${quagga_daemons}" = "${quagga_daemons% ${name}}" ]; then
@@ -40,22 +45,22 @@
fi
if [ ${quagga_wait_for} ]; then
echo Waiting for ${quagga_wait_for} route...
- while true; do
+ while : ; do
/sbin/route -n get ${quagga_wait_for} >/dev/null 2>&1 && break;
sleep 1;
done
fi
}
-stop_postcmd()
+quagga_poststop()
{
rm -f $pidfile
}
do_cmd()
{
- local ret
- ret=0
+ local daemon
+
for daemon in ${quagga_daemons}; do
command=%%PREFIX%%/sbin/${daemon}
required_files=%%SYSCONF_DIR%%/${daemon}.conf
@@ -69,9 +74,8 @@
eval flags=\$\{${daemon}_flags:-\"${quagga_flags}\"\}
name=${daemon}
_rc_restart_done=false
- run_rc_command "$1" || ret=1
+ run_rc_command "$1" || return 1
done
- return ${ret}
}
# set defaults
@@ -81,8 +85,6 @@
: ${quagga_enable="NO"}
: ${quagga_flags="-d"}
: ${quagga_daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"}
-: ${quagga_extralibs_path=""}
-: ${quagga_wait_for=""}
quagga_cmd=$1
More information about the cvs-ports
mailing list