rpms/ez-ipupdate/devel ez-ipupdate.init, 1.1, 1.2 ez-ipupdate.spec, 1.8, 1.9

Jeff Layton (jlayton) fedora-extras-commits at redhat.com
Sun Jul 2 21:16:45 UTC 2006


Author: jlayton

Update of /cvs/extras/rpms/ez-ipupdate/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17279

Modified Files:
	ez-ipupdate.init ez-ipupdate.spec 
Log Message:
New init script that handles multiple conf files.
Specfile changes to accomodate new config/pid/lockfile locations



Index: ez-ipupdate.init
===================================================================
RCS file: /cvs/extras/rpms/ez-ipupdate/devel/ez-ipupdate.init,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ez-ipupdate.init	8 Nov 2004 04:15:56 -0000	1.1
+++ ez-ipupdate.init	2 Jul 2006 21:16:44 -0000	1.2
@@ -6,15 +6,13 @@
 #
 # processname: ez-ipupdate
 # description: Check and update your IP to dynamic DNS Server.
-# pidfile: /var/run/ez-ipupdate/ez-ipudpate.pid
-# config: /etc/ez-ipupdate.conf
 
-ez_config=/etc/ez-ipupdate.conf
+ez_configdir=/etc/ez-ipupdate
+ez_piddir=/var/run/ez-ipupdate
 ez_bin=/usr/sbin/ez-ipupdate
-ez_pid=/var/run/ez-ipupdate/ez-ipupdate.pid
 
 # Make sure relevant files exist
-[ -x "$ez_bin" -a -s "$ez_config" ] || exit 0
+[ -x "$ez_bin" -a -d "$ez_configdir" ] || exit 0
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -30,28 +28,50 @@
 
 start() {
     # Start daemons.
-    echo -n $"Starting $prog: "
-    daemon $ez_bin --daemon --config-file $ez_config --pid-file $ez_pid
-    RETVAL=$?
-    echo
-    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
+    for ez_configfile in ${ez_configdir}/*.conf; do
+	if [ -r ${ez_configfile} ]; then
+	    # Don't run configurations that are not daemons
+	    if ! grep -q '^ *daemon' ${ez_configfile}; then continue; fi
+	    # Don't run configurations that run in foreground
+	    if grep -q '^ *foreground' ${ez_configfile}; then continue; fi
+	    ez_name=`basename $ez_configfile .conf`
+	    echo -n $"Starting $prog for $ez_name: "
+	    daemon $ez_bin --daemon --config-file $ez_configfile --pid-file $ez_piddir/$ez_name.pid
+	    error=$?
+	    echo
+	    [ $error -eq 0 ] && touch /var/lock/subsys/$prog-$ez_name
+	    [ $RETVAL -eq 0 ] && RETVAL=$error
+	fi
+    done
 }
 
 stop() {
     # Stop daemons.
-    echo -n $"Shutting down $prog: "
-    killproc $prog -QUIT
-    RETVAL=$?
-    echo
-    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog && rm -f $ez_pid
+    for pidfile in ${ez_piddir}/*.pid; do
+	if [ -r ${pidfile} ]; then
+	    ez_name=`basename $pidfile .pid`
+	    echo -n $"Shutting down $prog for $ez_name: "
+	    killproc -p $pidfile $prog -QUIT
+	    error=$?
+	    echo
+    	    [ $error -eq 0 ] && rm -f /var/lock/subsys/$prog-$ez_name && rm -f $ez_piddir/$ez_name
+	    [ $RETVAL -eq 0 ] && RETVAL=$error
+	fi
+    done
 }
 
 reload() {
     # Reload config by sending a SIGHUP.
-    echo -n $"Reloading $prog: "
-    killproc $prog -HUP
-    RETVAL=$?
-    echo
+    for pidfile in ${ez_piddir}/*.pid; do
+	if [ -r ${pidfile} ]; then
+	    ez_name=`basename $pidfile .pid`
+	    echo -n $"Reloading $prog for $ez_name: "
+	    killproc -p $pidfile $prog -HUP
+	    error=$?
+	    [ $RETVAL -eq 0 ] && RETVAL=$error
+	    echo
+	fi
+    done
 }
 
 restart() {
@@ -71,20 +91,24 @@
   restart)
     restart
     ;;
-  reload)
+  reload|force-reload)
     reload
     ;;
-  condrestart)
-    [ -e /var/lock/subsys/$prog ] && restart || :
+  condrestart|try-restart)
+    ls /var/lock/subsys/$prog-* 1>/dev/null 2>&1 && restart
     ;;
   status)
     status $prog
     RETVAL=$?
-    if [ -r $ez_config ]; then
-      ez_cache=`grep -E '^[[:space:]]*cache-file' $ez_config | cut -d "=" -f2`
-      [ -n "$ez_cache" ] && \
-        echo "Last IP update: "`cat $ez_cache | cut -d "," -f2`
-    fi
+    for ez_config in $ez_configdir/*.conf; do
+	if [ -r $ez_config ]; then
+	    ez_cache=`grep -E '^[[:space:]]*cache-file' $ez_config | cut -d "=" -f2`
+	    ez_host=`grep -E '^[[:space:]]*host' $ez_config | cut -d "=" -f2`
+	    ez_iface=`grep -E '^[[:space:]]*interface' $ez_config | cut -d "=" -f2`
+	    [ -n "$ez_cache" ] && \
+	    echo "Last IP update of $ez_host on $ez_iface: "`cat $ez_cache | cut -d "," -f2`
+	fi
+    done
     ;;
   *)
     echo "Usage: $0 {start|stop|restart|condrestart|reload|status}"


Index: ez-ipupdate.spec
===================================================================
RCS file: /cvs/extras/rpms/ez-ipupdate/devel/ez-ipupdate.spec,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ez-ipupdate.spec	15 Feb 2006 19:16:36 -0000	1.8
+++ ez-ipupdate.spec	2 Jul 2006 21:16:44 -0000	1.9
@@ -1,6 +1,6 @@
 Name:           ez-ipupdate
 Version:        3.0.11
-Release:        0.9.b8%{?dist}
+Release:        0.10.b8%{?dist}
 Summary:        Client for Dynamic DNS Services
 
 Group:          Applications/Internet
@@ -69,13 +69,15 @@
 mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/ez-ipupdate
 > $RPM_BUILD_ROOT%{_localstatedir}/cache/ez-ipupdate/default-cache
 
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
-> $RPM_BUILD_ROOT%{_sysconfdir}/ez-ipupdate.conf
+# Make a directory for config files
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/ez-ipupdate
+> $RPM_BUILD_ROOT%{_sysconfdir}/ez-ipupdate/default.conf
 
 # Create a dedicated dir for the pid file so we can run as non-root.
 mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/ez-ipupdate
 
 
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -87,6 +89,13 @@
 
 %post
 /sbin/chkconfig --add ez-ipupdate
+# move config file from old location to new if it exists
+if [ $1 -ge 1 ]; then
+    [ -f %{_sysconfdir}/ez-ipupdate.conf ] && /bin/mv %{_sysconfdir}/ez-ipupdate.conf %{_sysconfdir}/ez-ipupdate/default.conf
+    [ -f %{_localstatedir}/run/ez-ipupdate/ez-ipupdate.pid ] && /bin/mv %{_localstatedir}/run/ez-ipupdate/ez-ipupdate.pid %{_localstatedir}/run/ez-ipupdate/default.pid
+    [ -f %{_localstatedir}/lock/subsys/ez-ipupdate ] && /bin/mv %{_localstatedir}/lock/subsys/ez-ipupdate %{_localstatedir}/lock/subsys/ez-ipupdate-default
+    %{_initrddir}/ez-ipupdate condrestart >/dev/null
+fi
 
 %preun
 if [ $1 -eq 0 ] ; then
@@ -98,26 +107,27 @@
 if [ $1 -eq 0 ] ; then
   /usr/sbin/userdel ez-ipupd >/dev/null 2>&1 || :
   /usr/sbin/groupdel ez-ipupd >/dev/null 2>&1 || :
-elif [ $1 -ge 1 ] ; then
-  %{_initrddir}/ez-ipupdate condrestart >/dev/null
 fi
 
-
 %files
-%defattr(0644,root,root,0755)
-%doc CHANGELOG COPYING README example-*.conf
+%defattr(-,root,root,-)
 %{_mandir}/man8/ez-ipupdate.8*
-%defattr(0755,root,root,0755)
 %attr(0755,root,root) %{_sbindir}/ez-ipupdate
 %attr(0755,root,root) %{_initrddir}/ez-ipupdate
-%defattr(0644,ez-ipupd,ez-ipupd,0755)
+%dir %{_sysconfdir}/ez-ipupdate/
+%defattr(0644,root,root,-)
+%doc CHANGELOG COPYING README example-*.conf
+%defattr(-,ez-ipupd,ez-ipupd,-)
 %dir %{_localstatedir}/cache/ez-ipupdate/
-%ghost %{_localstatedir}/cache/ez-ipupdate/default-cache
 %dir %{_localstatedir}/run/ez-ipupdate/
-%ghost %attr(0640,root,ez-ipupd) %config(noreplace,missingok) %{_sysconfdir}/ez-ipupdate.conf
-
+%ghost %{_localstatedir}/cache/ez-ipupdate/default-cache
+%ghost %attr(0640,root,ez-ipupd) %config(noreplace,missingok) %{_sysconfdir}/ez-ipupdate/default.conf
 
 %changelog
+* Sat Jul 1 2006 Jeff Layton <jlayton at redhat.com> - 3.0.11-0.10.b8
+- new init script that can handle more than one config file
+- move config files into directory under sysconfdir
+
 * Wed Feb 15 2006 Ville Skyttä <ville.skytta at iki.fi> - 3.0.11-0.9.b8
 - Sync with Debian's 3.0.11b8-10.
 




More information about the fedora-extras-commits mailing list