OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-src openpkg-web Date: 23-Jul-2003 14:25:25
Branch: HEAD Handle: 2003072313252401
Added files:
openpkg-src/portfwd portfwd.patch
Modified files:
openpkg-src/portfwd portfwd.spec rc.portfwd
openpkg-web news.txt
Log:
%status and pidfile handling
Summary:
Revision Changes Path
1.1 +123 -0 openpkg-src/portfwd/portfwd.patch
1.34 +3 -1 openpkg-src/portfwd/portfwd.spec
1.14 +23 -2 openpkg-src/portfwd/rc.portfwd
1.5746 +1 -0 openpkg-web/news.txt
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-src/portfwd/portfwd.patch
============================================================================
$ cvs diff -u -r0 -r1.1 portfwd.patch
--- /dev/null 2003-07-23 14:25:25.000000000 +0200
+++ portfwd.patch 2003-07-23 14:25:25.000000000 +0200
@@ -0,0 +1,123 @@
+--- src/portfwd.cc.dist 2003-07-23 13:30:00.000000000 +0200
++++ src/portfwd.cc 2003-07-23 14:22:44.000000000 +0200
+@@ -36,6 +36,8 @@
+
+ int on_the_fly_dns = 0;
+ int foreground = 0;
++int dmz = -1;
++const char *pidfile = NULL;
+
+ void usage(FILE *out)
+ {
+@@ -52,6 +54,7 @@
+ " -f | --on-the-fly-dns\n"
+ " -g | --foreground\n"
+ " -c <config-file> | --config <config-file>\n",
++ " -p <pid-file> | --pidfile <pid-file>\n",
+ prog);
+ }
+
+@@ -81,14 +84,16 @@
+ {"on-the-fly-dns", 0, 0, 'f'},
+ {"foreground", 0, 0, 'g'},
+ {"config", 1, 0, 'c'},
++ {"pidfile", 1, 0, 'p'},
+ {0, 0, 0, 0}
+ };
+
+ *config = 0;
++ pidfile = 0;
+
+ for (;;) {
+
+- opt = getopt_long(argc, (char ** const) argv, "hvdtfgc:", long_options,
&option_index);
++ opt = getopt_long(argc, (char ** const) argv, "hvdtfgc:p:", long_options,
&option_index);
+ if (opt == -1)
+ break;
+
+@@ -124,6 +129,13 @@
+ }
+ *config = optarg;
+ break;
++ case 'p':
++ if (pidfile) {
++ fprintf(stderr, "%s: Pid-file redefinition: %s", me, optarg);
++ exit(1);
++ }
++ pidfile = optarg;
++ break;
+ case '?':
+ usage(stderr);
+ exit(1);
+@@ -245,6 +257,9 @@
+
+ closelog();
+
++ if (!dmz && pidfile)
++ unlink(pidfile);
++
+ exit(0);
+ }
+
+@@ -290,7 +305,7 @@
+ * Go to background.
+ */
+ if (!foreground) {
+- int dmz = daemonize();
++ dmz = daemonize(pidfile);
+ if (dmz) {
+ syslog(LOG_ERR, "daemonize() failed: %d", dmz);
+ exit(1);
+--- src/portfwd.h.dist 2003-07-23 13:32:46.000000000 +0200
++++ src/portfwd.h 2003-07-23 13:32:56.000000000 +0200
+@@ -20,6 +20,7 @@
+
+ extern int on_the_fly_dns;
+ extern int foreground;
++extern const char *pidfile;
+
+ #endif /* PORTFWD_H */
+
+--- src/util.cc.dist 2003-07-23 13:40:04.000000000 +0200
++++ src/util.cc 2003-07-23 14:15:35.000000000 +0200
+@@ -135,7 +135,7 @@
+ return 0;
+ }
+
+-int daemonize()
++int daemonize(const char *pidfile)
+ {
+ ONVERBOSE(syslog(LOG_INFO, "Daemonizing"));
+
+@@ -163,6 +163,20 @@
+ return -1;
+ }
+
++ if (pidfile) {
++ int pidfd;
++ size_t n;
++ char buf[20];
++ n = snprintf(buf,sizeof(buf),"%lu",(unsigned long)pid);
++ if (n < sizeof(buf)) {
++ pidfd = open(pidfile, O_CREAT|O_TRUNC|O_WRONLY, 0666);
++ if (pidfd != -1) {
++ write(pidfd,buf,n);
++ close(pidfd);
++ }
++ }
++ }
++
+ /*
+ * Parent exits
+ */
+--- src/util.h.dist 2003-07-23 14:09:04.000000000 +0200
++++ src/util.h 2003-07-23 14:09:13.000000000 +0200
+@@ -29,7 +29,7 @@
+ int cd_root();
+ void close_fds(int first_fd);
+ int std_to_null();
+-int daemonize();
++int daemonize(const char *pidfile);
+
+ void socket_close(int fd);
+
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/portfwd/portfwd.spec
============================================================================
$ cvs diff -u -r1.33 -r1.34 portfwd.spec
--- openpkg-src/portfwd/portfwd.spec 22 Jul 2003 08:10:59 -0000 1.33
+++ openpkg-src/portfwd/portfwd.spec 23 Jul 2003 12:25:25 -0000 1.34
@@ -33,7 +33,7 @@
Group: Network
License: GPL
Version: 0.26rc6
-Release: 20030722
+Release: 20030723
# package options
%option with_fsl yes
@@ -43,6 +43,7 @@
Source1: portfwd.cfg
Source2: rc.portfwd
Source3: fsl.portfwd
+Patch0: portfwd.patch
# build information
Prefix: %{l_prefix}
@@ -65,6 +66,7 @@
%prep
%setup -q
+ %patch -p0
# patch source tree
%{l_shtool} subst \
@@ .
patch -p0 <<'@@ .'
Index: openpkg-src/portfwd/rc.portfwd
============================================================================
$ cvs diff -u -r1.13 -r1.14 rc.portfwd
--- openpkg-src/portfwd/rc.portfwd 22 Jul 2003 08:10:59 -0000 1.13
+++ openpkg-src/portfwd/rc.portfwd 23 Jul 2003 12:25:25 -0000 1.14
@@ -12,13 +12,34 @@
portfwd_log_minsize="1M"
portfwd_log_complevel="9"
+%common
+ portfwd_pidfile="@l_prefix@/var/portfwd/portfwd.pid"
+ portfwd_signal () {
+ [ -f $portfwd_pidfile ] && kill -$1 `cat $portfwd_pidfile`
+ }
+
+%status -u @l_susr@ -o
+ portfwd_usable="unknown"
+ portfwd_active="no"
+ rcService portfwd enable yes && \
+ portfwd_signal 0 && portfwd_active="yes"
+ echo "portfwd_enable=\"$portfwd_enable\""
+ echo "portfwd_usable=\"$portfwd_usable\""
+ echo "portfwd_active=\"$portfwd_active\""
+
%start -u @l_susr@
rcService portfwd enable yes || exit 0
- @l_prefix@/sbin/portfwd $portfwd_flags
+ @l_prefix@/sbin/portfwd -p $portfwd_pidfile $portfwd_flags
%stop -u @l_susr@
rcService portfwd enable yes || exit 0
- rpmtool signal -d 1 -m @l_prefix@/sbin/portfwd TERM KILL >/dev/null 2>&1 || true
+ portfwd_signal TERM
+
+%restart -u @l_susr@
+ rcService portfwd enable yes || exit 0
+ rc portfwd stop
+ sleep 2
+ rc portfwd start
%daily -u @l_susr@
rcService portfwd enable yes || exit 0
@@ .
patch -p0 <<'@@ .'
Index: openpkg-web/news.txt
============================================================================
$ cvs diff -u -r1.5745 -r1.5746 news.txt
--- openpkg-web/news.txt 23 Jul 2003 10:22:41 -0000 1.5745
+++ openpkg-web/news.txt 23 Jul 2003 12:25:24 -0000 1.5746
@@ -1,3 +1,4 @@
+23-Jul-2003: Upgraded package: P<portfwd-0.26rc6-20030723>
23-Jul-2003: Upgraded package: P<lmtp2nntp-1.2.0-20030723>
23-Jul-2003: Upgraded package: P<pks-0.9.6-20030723>
23-Jul-2003: Upgraded package: P<pb4sd-1.2-20030723>
@@ .
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]