2003-12-30 Paul Jakma <paul@dishone.st>

        * redhat/isisd.init: new file, init script for isisd.
          redhat/quagga.sysconfig: new file, sysconfig file for quagga
          initscripts.
          redhat/quagga.spec.in: various cleanups, including sysconfig patch
          from RH, fixed UID/GID as per RH EL, shell changed to
          /sbin/nologin, daemon vty's listen to 127.1 only per default and
          isisd packaged.
          redhat/*.init: sysconfig support and runlevels specified.
diff --git a/redhat/bgpd.init b/redhat/bgpd.init
index 296b915..ef59c2a 100644
--- a/redhat/bgpd.init
+++ b/redhat/bgpd.init
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig: - 16 84
+# chkconfig: 2345 16 84
 # description: A BGPv4, BGPv4+, BGPv4- routing engine for use with Zebra
 #
 # processname: bgpd
@@ -12,6 +12,9 @@
 # Get network config
 . /etc/sysconfig/network
 
+# quagga command line options
+. /etc/sysconfig/quagga
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 0
 
@@ -24,7 +27,7 @@
 case "$1" in
   start)
 	echo -n $"Starting $prog: "
-        daemon /usr/sbin/bgpd -d
+        daemon /usr/sbin/bgpd -d $BGPD_OPTS
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/bgpd
 	echo
diff --git a/redhat/isisd.init b/redhat/isisd.init
new file mode 100644
index 0000000..0d762c0
--- /dev/null
+++ b/redhat/isisd.init
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# chkconfig: 2345 16 84
+# description: An ISIS routing engine for use with Quagga
+#
+# processname: isisd
+# config: /etc/quagga/isisd.conf
+
+# source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ "${NETWORKING}" = "no" ] && exit 0
+
+# The process must be configured first.
+[ -f /etc/quagga/isisd.conf ] || exit 0
+
+RETVAL=0
+
+prog="isisd"
+
+case "$1" in
+  start)
+	echo -n $"Starting $prog: "
+        daemon /usr/sbin/isisd -d
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/isisd
+	echo
+	;;
+  stop)
+	echo -n $"Shutting down $prog: "
+	killproc isisd
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/isisd
+	echo
+	;;
+  restart|reload)
+        $0 stop
+        $0 start
+	RETVAL=$?
+        ;;
+  condrestart)
+        if [ -f /var/lock/subsys/isisd ]; then
+                $0 stop
+		$0 start
+        fi
+	RETVAL=$?
+        ;;
+  status)
+        status isisd
+	RETVAL=$?
+        ;;
+  *)
+	echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
+	exit 1
+esac
+
+exit $RETVAL
diff --git a/redhat/ospf6d.init b/redhat/ospf6d.init
index a54a57e..c84ce67 100644
--- a/redhat/ospf6d.init
+++ b/redhat/ospf6d.init
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig: - 16 84
+# chkconfig: 2345 16 84
 # description: An OSPF routing engine for use with Zebra and IPv6
 #
 # processname: ospf6d
@@ -12,6 +12,9 @@
 # Get network config
 . /etc/sysconfig/network
 
+# quagga command line options
+. /etc/sysconfig/quagga
+
 # Check that networking is up.
 [ "${NETWORKING_IPV6}" = "no" ] && exit 0
 
@@ -24,7 +27,7 @@
 case "$1" in
   start)
 	echo -n $"Starting $prog: "
-        daemon /usr/sbin/ospf6d -d
+        daemon /usr/sbin/ospf6d -d $OSPF6D_OPTS
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ospf6d
 	echo
diff --git a/redhat/ospfd.init b/redhat/ospfd.init
index 8e3dae6..911f7aa 100644
--- a/redhat/ospfd.init
+++ b/redhat/ospfd.init
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig: - 16 84
+# chkconfig: 2345 16 84
 # description: An OSPF v2 routing engine for use with Zebra
 #
 # processname: ospfd
@@ -12,6 +12,9 @@
 # Get network config
 . /etc/sysconfig/network
 
+# quagga command line options
+. /etc/sysconfig/quagga
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 0
 
@@ -25,7 +28,7 @@
 case "$1" in
   start)
 	echo -n $"Starting $prog: "
-        daemon /usr/sbin/ospfd -d
+        daemon /usr/sbin/ospfd -d $OSPFD_OPTS
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ospfd
 	echo
diff --git a/redhat/quagga.spec.in b/redhat/quagga.spec.in
index 5308cc4..2512d31 100644
--- a/redhat/quagga.spec.in
+++ b/redhat/quagga.spec.in
@@ -22,10 +22,19 @@
 
 # defines for configure
 %define		_libexecdir	%{_exec_prefix}/libexec/quagga
-%define		_includedir	%{_prefix}/include/quagga
 %define		_libdir		%{_exec_prefix}/%{_lib}/quagga
+%define		_includedir	%{_prefix}/include
 %define		_localstatedir	/var/run/quagga
 
+# misc internal defines
+%define         quagga_uid      92
+%define         quagga_gid      92
+%if %with_ipv6
+%define		daemon_list	zebra ripd isisd ospfd ripngd ospf6d bgpd
+%else
+%define		daemon_list	zebra ripd isisd ospfd bgpd
+%endif
+
 Summary: Routing daemon
 Name:		quagga
 Version:	@VERSION@
@@ -35,14 +44,14 @@
 Source0:	http://www.quagga.net/snapshots/cvs/%{name}-%{version}.tar.gz
 URL:		http://www.quagga.net
 %if %with_snmp
-#BuildRequires:	ucd-snmp-devel
+BuildRequires:	ucd-snmp-devel
 Prereq:		ucd-snmp
 %endif
 %if %with_vtysh
 BuildRequires:	readline readline-devel ncurses ncurses-devel
 Prereq:		readline ncurses
 %endif
-BuildRequires:	texinfo tetex autoconf pam-devel patch
+BuildRequires:	texinfo tetex autoconf pam-devel patch libcap-devel
 # Initscripts > 5.60 is required for IPv6 support
 Prereq:		initscripts >= 5.60
 Prereq:		ncurses readline pam
@@ -148,16 +157,17 @@
 # Remove this file, as it is uninstalled and causes errors when building on RH9
 rm -rf $RPM_BUILD_ROOT/usr/share/info/dir
 
-install %{zeb_rh_src}/zebra.init $RPM_BUILD_ROOT/etc/rc.d/init.d/zebra
-install %{zeb_rh_src}/bgpd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/bgpd
-%if %with_ipv6
-install %{zeb_rh_src}/ospf6d.init $RPM_BUILD_ROOT/etc/rc.d/init.d/ospf6d
-install %{zeb_rh_src}/ripngd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/ripngd
-%endif
-install %{zeb_rh_src}/ospfd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/ospfd
-install %{zeb_rh_src}/ripd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/ripd
-install -m644 %{zeb_rh_src}/quagga.pam $RPM_BUILD_ROOT/etc/pam.d/quagga
-install -m644 %{zeb_rh_src}/quagga.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/quagga
+# install etc sources
+for daemon in %daemon_list ; do
+	install %{zeb_rh_src}/${daemon}.init \
+		$RPM_BUILD_ROOT/etc/rc.d/init.d/${daemon}
+done
+install -m644 %{zeb_rh_src}/quagga.pam \
+	$RPM_BUILD_ROOT/etc/pam.d/quagga
+install -m644 %{zeb_rh_src}/quagga.logrotate \
+	$RPM_BUILD_ROOT/etc/logrotate.d/quagga
+install -m644 %{zeb_rh_src}/quagga.sysconfig \
+	$RPM_BUILD_ROOT/etc/sysconfig/quagga
 install -d -m750  $RPM_BUILD_ROOT/var/run/quagga
 
 %pre
@@ -167,7 +177,9 @@
 %endif
 # add quagga user and group
 %if %quagga_user
-/usr/sbin/useradd -M -r -s /bin/false -c "Quagga routing suite" \
+/usr/sbin/groupadd -g %quagga_gid quagga 2> /dev/null || :
+/usr/sbin/useradd  -u %quagga_uid -g %quagga_gid \
+ -M -r -s /sbin/nologin -c "Quagga routing suite" \
  -d %_localstatedir %quagga_user 2> /dev/null || :
 %endif
 
@@ -199,14 +211,9 @@
 %endif
 zebra_spec_add_service isisd    2608/tcp "ISISd vty"
 
-/sbin/chkconfig --add zebra 
-/sbin/chkconfig --add ripd
-%if %with_ipv6
-/sbin/chkconfig --add ripngd
-/sbin/chkconfig --add ospf6d
-%endif
-/sbin/chkconfig --add ospfd
-/sbin/chkconfig --add bgpd
+for daemon in %daemon_list ; do
+	/sbin/chkconfig --add ${daemon}
+done
 
 /sbin/install-info %{_infodir}/quagga.info.gz %{_infodir}/dir
 
@@ -222,31 +229,18 @@
 
 %postun
 if [ "$1" -ge  "1" ]; then
-	/etc/rc.d/init.d/zebra  condrestart >/dev/null 2>&1
-	/etc/rc.d/init.d/ripd   condrestart >/dev/null 2>&1
-%if %with_ipv6
-	/etc/rc.d/init.d/ripngd condrestart >/dev/null 2>&1
-%endif
-	/etc/rc.d/init.d/ospfd  condrestart >/dev/null 2>&1
-%if %with_ipv6
-	/etc/rc.d/init.d/ospf6d condrestart >/dev/null 2>&1
-%endif
-	/etc/rc.d/init.d/bgpd   condrestart >/dev/null 2>&1
+	for daemon in %daemon_list ; do
+		/etc/rc.d/init.d/${daemon} condrestart >/dev/null 2>&1
+	done
 fi
-/sbin/install-info --delete %{_infodir}/quagga.info.gz %{_infodir}/dir
 
 %preun
 if [ "$1" = "0" ]; then
-        /sbin/chkconfig --del zebra
-	/sbin/chkconfig --del ripd
-%if %with_ipv6
-	/sbin/chkconfig --del ripngd
-%endif
-	/sbin/chkconfig --del ospfd
-%if %with_ipv6
-	/sbin/chkconfig --del ospf6d
-%endif
-	/sbin/chkconfig --del bgpd
+	for daemon in %daemon_list ; do
+		/etc/rc.d/init.d/${daemon} stop  >/dev/null 2>&1
+		/sbin/chkconfig --del ${daemon}
+	done
+	/sbin/install-info --delete %{_infodir}/quagga.info.gz %{_infodir}/dir
 fi
 
 %clean
@@ -279,6 +273,7 @@
 %endif
 %config /etc/quagga/[!v]*
 %config /etc/rc.d/init.d/*
+%config(noreplace) /etc/sysconfig/quagga
 %config(noreplace) /etc/pam.d/quagga
 %config(noreplace) %attr(640,root,root) /etc/logrotate.d/*
 
@@ -289,13 +284,25 @@
 %files devel
 %defattr(-,root,root)
 %dir %{_libdir}/*
-%dir %{_includedir}/*.h
-%dir %{_includedir}/ospfd/*
+%dir %{_includedir}/%name/*.h
+%dir %{_includedir}/%name/ospfd/*.h
 %if %with_ospfapi
-%dir %{_includedir}/ospfapi/*
+%dir %{_includedir}/%name/ospfapi/*.h
 %endif
 
 %changelog
+%changelog
+* Tue Dec 30 2003 Paul Jakma <paul@dishone.st>
+- sync to CVS
+- integrate RH sysconfig patch to specify daemon options (RH)
+- default to have vty listen only to 127.1 (RH)
+- add user with fixed UID/GID (RH)
+- create user with shell /sbin/nologin rather than /bin/false (RH)
+- stop daemons on uninstall (RH)
+- delete info file on %preun, not %postun to avoid deletion on upgrade. (RH)
+- isisd added
+- cleanup tasks carried out for every daemon
+
 * Sun Nov 2 2003 Paul Jakma <paul@dishone.st>
 - Fix -devel package to include all files
 - Sync to 0.96.4
diff --git a/redhat/quagga.sysconfig b/redhat/quagga.sysconfig
new file mode 100644
index 0000000..fc905af
--- /dev/null
+++ b/redhat/quagga.sysconfig
@@ -0,0 +1,9 @@
+#
+# Default: Bind all daemon vtys to the loopback(s) only
+#
+BGPD_OPTS="-A 127.0.0.1"
+OSPF6D_OPTS="-A ::1"
+OSPFD_OPTS="-A 127.0.0.1"
+RIPD_OPTS="-A 127.0.0.1"
+RIPNGD_OPTS="-A ::1"
+ZEBRA_OPTS="-A 127.0.0.1"
diff --git a/redhat/ripd.init b/redhat/ripd.init
index 3545a74..7664221 100644
--- a/redhat/ripd.init
+++ b/redhat/ripd.init
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig: - 16 84
+# chkconfig: 2345 16 84
 # description: A RIP routing engine for use with Zebra
 #
 # processname: ripd
@@ -12,6 +12,9 @@
 # Get network config
 . /etc/sysconfig/network
 
+# quagga command line options
+. /etc/sysconfig/quagga
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 0
 
@@ -24,7 +27,7 @@
 case "$1" in
   start)
 	echo -n $"Starting $prog: "
-        daemon /usr/sbin/ripd -d
+        daemon /usr/sbin/ripd -d $RIPD_OPTS
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ripd
 	echo
diff --git a/redhat/ripngd.init b/redhat/ripngd.init
index 4d552e3..57ae928 100644
--- a/redhat/ripngd.init
+++ b/redhat/ripngd.init
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig: - 16 84
+# chkconfig: 2345 16 84
 # description: A RIP routing engine for use with Zebra and IPv6
 #
 # processname: ripngd
@@ -12,6 +12,9 @@
 # Get network config
 . /etc/sysconfig/network
 
+# quagga command line options
+. /etc/sysconfig/quagga
+
 # Check that networking is up.
 [ "${NETWORKING_IPV6}" = "no" ] && exit 0
 
@@ -24,7 +27,7 @@
 case "$1" in
   start)
 	echo -n $"Starting $prog: "
-        daemon /usr/sbin/ripngd -d
+        daemon /usr/sbin/ripngd -d $RIPNGD_OPTS
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ripngd
 	echo
diff --git a/redhat/zebra.init b/redhat/zebra.init
index 16b7a49..8caae1f 100644
--- a/redhat/zebra.init
+++ b/redhat/zebra.init
@@ -1,6 +1,6 @@
 #!/bin/bash
 #
-# chkconfig: - 15 85
+# chkconfig: 2345 15 85
 # description: GNU Zebra routing manager
 #
 # processname: zebra
@@ -9,6 +9,9 @@
 # source function library
 . /etc/rc.d/init.d/functions
 
+# quagga command line options
+. /etc/sysconfig/quagga
+
 # Check that networking is up.
 [ "${NETWORKING}" = "no" ] && exit 0
 
@@ -25,7 +28,7 @@
 
 	/sbin/ip route flush proto zebra
 			
-        daemon /usr/sbin/zebra -d
+        daemon /usr/sbin/zebra -d $ZEBRA_OPTS
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/zebra
 	echo