changeset 27:9298f8b00db2 stable-1-0-10

patches from Takao Abe add switches for config and pid files
author Carl Byington <carl@five-ten-sg.com>
date Thu, 24 May 2018 10:35:45 -0700
parents c6d5b1658f61
children 946961e534b4
files AUTHORS ChangeLog Makefile.am NEWS configure.in sm-archive.spec.in src/sm-archive.cpp xml/sm-archive.in
diffstat 8 files changed, 407 insertions(+), 363 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Mon Feb 06 12:08:35 2017 -0800
+++ b/AUTHORS	Thu May 24 10:35:45 2018 -0700
@@ -1,3 +1,4 @@
 510 Software Group <carl@five-ten-sg.com>
 Sergey Shapovalov <shasn@reso.ru>
 Marco d'Itri <md@Linux.IT>
+Takao Abe <takao_abe@fitserv.co.jp>
--- a/ChangeLog	Mon Feb 06 12:08:35 2017 -0800
+++ b/ChangeLog	Thu May 24 10:35:45 2018 -0700
@@ -1,3 +1,7 @@
+1.10 2018-05-24
+    patches from Takao Abe to add command line switches for the
+    config and pid files.
+
 1.9 2017-02-06
     changes for rhel7 systemd and /var/run on tmpfs
 
--- a/Makefile.am	Mon Feb 06 12:08:35 2017 -0800
+++ b/Makefile.am	Thu May 24 10:35:45 2018 -0700
@@ -2,12 +2,12 @@
 
 SUBDIRS = src man html info
 hackdir = $(sysconfdir)/sm-archive
-hack_SCRIPTS = sm-archive sm-archive.service sm-archive-tmpfs.conf
-hack_DATA = sm-archive.conf
+hack_SCRIPTS = sm-archive sm-archive.service
+hack_DATA = sm-archive.conf sm-archive-tmpfs.conf
 htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@
 html_DATA = AUTHORS COPYING ChangeLog NEWS README
 CLEANFILES = sm-archive.service sm-archive xml/sm-archive xml/Makefile
-EXTRA_DIST = sm-archive-tmpfs.conf sm-archive.service.rc sm-archive.rc $(hack_DATA) sm-archive.spec $(wildcard m4/*) $(wildcard xml/h*) $(wildcard xml/M*) $(wildcard xml/sm*)
+EXTRA_DIST = sm-archive.service.rc sm-archive.rc $(hack_DATA) sm-archive.spec $(wildcard m4/*) $(wildcard xml/h*) $(wildcard xml/M*) $(wildcard xml/sm*)
 
 sm-archive: sm-archive.rc
 	   cat $(srcdir)/sm-archive.rc     | \
--- a/NEWS	Mon Feb 06 12:08:35 2017 -0800
+++ b/NEWS	Thu May 24 10:35:45 2018 -0700
@@ -1,3 +1,4 @@
+1.10 2018-05-24 patches from Takao Abe add switches for config and pid files
 1.9  2017-02-06 changes for rhel7 systemd and /var/run on tmpfs
 1.8  2010-12-24 patches from Marco d'Itri for postfix
 1.7  2008-06-12 Fedora 9 compile and const correctness.
--- a/configure.in	Mon Feb 06 12:08:35 2017 -0800
+++ b/configure.in	Thu May 24 10:35:45 2018 -0700
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT(sm-archive,1.9,carl@five-ten-sg.com)
+AC_INIT(sm-archive,1.10,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 
--- a/sm-archive.spec.in	Mon Feb 06 12:08:35 2017 -0800
+++ b/sm-archive.spec.in	Thu May 24 10:35:45 2018 -0700
@@ -129,6 +129,10 @@
 
 
 %changelog
+* Thu May 24 2018 Carl Byington <carl@five-ten-sg.com> - 1.10-1
+- patches from Takao Abe to add command line switches for the
+  config and pid files.
+
 * Mon Feb 06 2017 Carl Byington <carl@five-ten-sg.com> - 1.9-1
 - enable rhel7 systemd and /var/run is on tmpfs
 
--- a/src/sm-archive.cpp	Mon Feb 06 12:08:35 2017 -0800
+++ b/src/sm-archive.cpp	Thu May 24 10:35:45 2018 -0700
@@ -56,7 +56,11 @@
 	void sig_chld(int signo);
 }
 
+// command line options
+const char  *optionConfigFile = "sm-archive.conf" ;
+const char  *optionPidFile    = "/var/run/sm-archive.pid" ;
 int  debug_syslog  = 0;
+//
 bool syslog_opened = false;
 bool use_syslog    = true;	// false to printf
 bool loader_run    = true;	// used to stop the config loader thread
@@ -293,7 +297,7 @@
 		snprintf(buf, sizeof(buf), "loading configuration generation %d", newc->generation);
 		my_syslog(buf);
 	}
-	if (load_conf(*newc, "sm-archive.conf")) {
+    if (load_conf(*newc, optionConfigFile)) {
 		newc->load_time = time(NULL);
 		return newc;
 	}
@@ -349,13 +353,15 @@
 void usage(const char *prog);
 void usage(const char *prog)
 {
-	fprintf(stderr, "Usage: %s  [-d [level]] [-c] -p sm-sock-addr [-t timeout]\n", prog);
+    fprintf(stderr, "Usage: %s  [-d [level]] [-c] -p sm-sock-addr [-t timeout] [-C config-file] [-P pid-file]\n", prog);
 	fprintf(stderr, "where sm-sock-addr is for the connection to sendmail\n");
 	fprintf(stderr, "    and should be one of\n");
 	fprintf(stderr, "        inet:port@ip-address\n");
 	fprintf(stderr, "        local:local-domain-socket-file-name\n");
 	fprintf(stderr, "-c will load and dump the config to stdout\n");
 	fprintf(stderr, "-d will set the syslog message level, currently 0 to 3\n");
+    fprintf(stderr, "-C specifies the config file, defaults to sm-archive.conf\n");
+    fprintf(stderr, "-P specifies the pid file, defaults to /var/run/sm-archive.pid\n");
 }
 
 
@@ -393,7 +399,7 @@
 	bool check	 = false;
 	bool setconn = false;
 	int c;
-	const char *args = "p:t:d:ch";
+    const char *args = "p:t:d:chC:P:";
 	extern char *optarg;
 
 	// Process command line options
@@ -433,6 +439,22 @@
 				else								   debug_syslog = atoi(optarg);
 				break;
 
+            case 'C':
+                if (optarg == NULL || *optarg == '\0') {
+                    fprintf( stderr, "Must specify the config file path: %s\n", optarg );
+                    exit(EX_USAGE);
+                }
+                optionConfigFile = optarg ;
+                break ;
+
+            case 'P':
+                if (optarg == NULL || *optarg == '\0') {
+                    fprintf( stderr, "Must specify the pid file path: %s\n", optarg );
+                    exit(EX_USAGE);
+                }
+                optionPidFile = optarg ;
+                break ;
+
 			case 'h':
 			default:
 				usage(argv[0]);
@@ -473,7 +495,7 @@
 	}
 
 	// write the pid
-	const char *pidpath = "/var/run/sm-archive.pid";
+    const char *pidpath = optionPidFile;
 	unlink(pidpath);
 	FILE *f = fopen(pidpath, "w");
 	if (f) {
--- a/xml/sm-archive.in	Mon Feb 06 12:08:35 2017 -0800
+++ b/xml/sm-archive.in	Thu May 24 10:35:45 2018 -0700
@@ -19,7 +19,7 @@
 
     <refentry id="@PACKAGE@.1">
         <refentryinfo>
-            <date>2008-03-21</date>
+            <date>2018-05-24</date>
         </refentryinfo>
 
         <refmeta>
@@ -73,6 +73,18 @@
                         Set the timeout in seconds used for communication with sendmail.
                     </para></listitem>
                 </varlistentry>
+                <varlistentry>
+                    <term>-C <replaceable class="parameter">config-file</replaceable></term>
+                    <listitem><para>
+                        Specify the config file, defaults to sm-archive.conf in the current directory.
+                    </para></listitem>
+                </varlistentry>
+                <varlistentry>
+                    <term>-P <replaceable class="parameter">pid-file</replaceable></term>
+                    <listitem><para>
+                        Specify the pid file, defaults to /var/run/sm-archive.pid
+                    </para></listitem>
+                </varlistentry>
             </variablelist>
         </refsect1>
 
@@ -178,7 +190,7 @@
 
     <refentry id="@PACKAGE@.conf.5">
         <refentryinfo>
-            <date>2008-03-21</date>
+            <date>2018-05-24</date>
         </refentryinfo>
 
         <refmeta>