View | Details | Raw Unified | Return to bug 265963 | Differences between
and this patch

Collapse All | Expand All

(-)b/sysutils/nut-devel/files/patch-configure.ac (-2 / +20 lines)
Added Link Here
0
- 
1
--- configure.ac.orig	2022-08-25 15:32:21.256937000 -0700
1
--
2
+++ configure.ac	2022-08-25 15:37:36.166445000 -0700
3
@@ -802,7 +802,7 @@
4
 
5
 dnl A Python GUI client application for the sysadmin desktop
6
 dnl (not necessarily on the NUT server itself):
7
-NUT_ARG_WITH([nut_monitor], [install the NUT-Monitor GUI files], [auto])
8
+NUT_ARG_WITH([nut_monitor], [install the NUT-Monitor GUI files], [no])
9
 NUT_ARG_WITH([pynut], [install the PyNUT module files (yes, no, app, auto)], [auto])
10
 dnl Note: we did NUT_CHECK_PYTHON2 NUT_CHECK_PYTHON3 etc above,
11
 dnl and if at all possible, we generate the files from .in templates
12
@@ -1301,7 +1301,7 @@
13
     dnl Can we satisfy any NUT-Monitor installation request?
14
     if test -n "${nut_with_nut_monitor_py2gtk2}${nut_with_nut_monitor_py3qt5}" ; then
15
         case "${nut_with_nut_monitor}" in
16
-            "auto") nut_with_nut_monitor="yes" ;;
17
+            "auto") nut_with_nut_monitor="no" ;;
18
         esac
19
     else
20
         case "${nut_with_nut_monitor}" in
2
sysutils/nut-devel/Makefile                   |   1 +
21
sysutils/nut-devel/Makefile                   |   1 +
3
.../nut-devel/files/patch-clients_upslog.c    | 166 ++++++++++++++++++
22
.../nut-devel/files/patch-clients_upslog.c    | 166 ++++++++++++++++++
4
.../nut-devel/files/patch-docs_man_upslog.txt |  16 ++
23
.../nut-devel/files/patch-docs_man_upslog.txt |  16 ++
5
sysutils/nut/Makefile                         |   2 +-
24
sysutils/nut/Makefile                         |   2 +-
6
sysutils/nut/files/patch-clients_upslog.c     | 166 ++++++++++++++++++
25
sysutils/nut/files/patch-clients_upslog.c     | 166 ++++++++++++++++++
7
sysutils/nut/files/patch-docs_man_upslog.8    |  16 ++
26
sysutils/nut/files/patch-docs_man_upslog.8    |  16 ++
8
.../nut/files/patch-include_nut__stdint.h     |  31 ++++
27
.../nut/files/patch-include_nut__stdint.h     |  31 ++++
9
7 files changed, 397 insertions(+), 1 deletion(-)
28
7 files changed, 397 insertions(+), 1 deletion(-)
10
create mode 100644 sysutils/nut-devel/files/patch-clients_upslog.c
29
create mode 100644 sysutils/nut-devel/files/patch-clients_upslog.c
11
create mode 100644 sysutils/nut-devel/files/patch-docs_man_upslog.txt
30
create mode 100644 sysutils/nut-devel/files/patch-docs_man_upslog.txt
12
create mode 100644 sysutils/nut/files/patch-clients_upslog.c
31
create mode 100644 sysutils/nut/files/patch-clients_upslog.c
13
create mode 100644 sysutils/nut/files/patch-docs_man_upslog.8
32
create mode 100644 sysutils/nut/files/patch-docs_man_upslog.8
14
create mode 100644 sysutils/nut/files/patch-include_nut__stdint.h
33
create mode 100644 sysutils/nut/files/patch-include_nut__stdint.h
(-)b/sysutils/nut-devel/Makefile (+1 lines)
Lines 1-5 Link Here
1
PORTNAME=	nut
1
PORTNAME=	nut
2
PORTVERSION=	${NUT_COMMIT_DATE}
2
PORTVERSION=	${NUT_COMMIT_DATE}
3
PORTREVISION=	1
3
CATEGORIES=	sysutils
4
CATEGORIES=	sysutils
4
PKGNAMESUFFIX=	-devel
5
PKGNAMESUFFIX=	-devel
5
# MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
6
# MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
(-)b/sysutils/nut-devel/files/patch-clients_upslog.c (+166 lines)
Added Link Here
1
--- clients/upslog.c.orig	2022-08-26 08:23:19.379731000 -0700
2
+++ clients/upslog.c	2022-08-26 08:35:00.260743000 -0700
3
@@ -32,6 +32,10 @@
4
  */
5
 
6
 #include "common.h"
7
+#include <signal.h>
8
+#include <unistd.h>
9
+#include <sys/types.h>
10
+#include <sys/wait.h>
11
 #include "nut_platform.h"
12
 #include "upsclient.h"
13
 
14
@@ -41,17 +45,32 @@
15
 #include "upslog.h"
16
 
17
 	static	int	reopen_flag = 0, exit_flag = 0;
18
+	static	int	wait_status;
19
 	static	uint16_t	port;
20
 	static	char	*upsname, *hostname;
21
 	static	UPSCONN_t	ups;
22
 
23
 	static	FILE	*logfile;
24
-	static	const	char *logfn, *monhost;
25
+	static	char *logfn, *monhost;
26
 	static	sigset_t	nut_upslog_sigmask;
27
 	static	char	logbuffer[LARGEBUF], *logformat;
28
 
29
 	static	flist_t	*fhead = NULL;
30
+	struct 	monhost_child {
31
+		char	*monhost;
32
+		char	*logfn;
33
+		char	*pidfilebase;
34
+		pid_t	pid;
35
+		struct	monhost_child	*next;
36
+	};
37
+	static	struct	monhost_child *monhost_child_anchor = NULL;
38
+	static	struct	monhost_child *monhost_child_current = NULL;
39
+	static	struct	monhost_child *monhost_child_prev = NULL;
40
+	static	struct	sigaction upslog_sigaction;
41
+	static	int	trapped_signals[] = { SIGINT, SIGTERM, SIGCHLD };
42
+	static	pid_t	daemon_pid;
43
 
44
+
45
 #define DEFAULT_LOGFORMAT "%TIME @Y@m@d @H@M@S% %VAR battery.charge% " \
46
 		"%VAR input.voltage% %VAR ups.load% [%VAR ups.status%] " \
47
 		"%VAR ups.temperature% %VAR input.frequency%"
48
@@ -131,6 +150,8 @@
49
 	printf("  -p <pidbase>  - Base name for PID file (defaults to \"%s\")\n", prog);
50
 	printf("  -s <ups>	- Monitor UPS <ups> - <upsname>@<host>[:<port>]\n");
51
 	printf("        	- Example: -s myups@server\n");
52
+	printf("  -m <tuple>	- Monitor UPS <ups,logfile,pidfile>,\n");
53
+	printf("		- Example: -m myups@server,/var/log/myups.log,/var/run/myups.pid\n");
54
 	printf("  -u <user>	- Switch to <user> if started as root\n");
55
 
56
 	printf("\n");
57
@@ -393,9 +414,24 @@
58
 	 * -u <username>
59
 	 */
60
 
61
+static void term_handler(int signo)
62
+{
63
+	if (signo != SIGCHLD && monhost_child_anchor != NULL) {
64
+		for (monhost_child_current = monhost_child_anchor;
65
+		     monhost_child_current != NULL;
66
+		     monhost_child_current = monhost_child_current->next
67
+		) {
68
+			kill(monhost_child_current->pid, signo);
69
+		}
70
+
71
+		fatalx(EXIT_FAILURE, "Killed by user");
72
+	}
73
+}
74
+
75
 int main(int argc, char **argv)
76
 {
77
 	int	interval = 30, i, foreground = -1;
78
+	size_t	monhost_len = 0, mh;
79
 	const char	*prog = xbasename(argv[0]);
80
 	time_t	now, nextpoll = 0;
81
 	const char	*user = NULL;
82
@@ -407,7 +443,7 @@
83
 
84
 	printf("Network UPS Tools %s %s\n", prog, UPS_VERSION);
85
 
86
-	while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FB")) != -1) {
87
+	while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FBm:")) != -1) {
88
 		switch(i) {
89
 			case 'h':
90
 				help(prog);
91
@@ -415,6 +451,33 @@
92
 				break;
93
 #endif
94
 
95
+			case 'm': { /* var scope */
96
+				char *m_arg, *s;
97
+
98
+				monhost_child_prev = monhost_child_current;
99
+				monhost_child_current = xmalloc(sizeof(struct monhost_child));
100
+				if (monhost_child_anchor == NULL)
101
+					monhost_child_anchor = monhost_child_current;
102
+				else
103
+					monhost_child_prev->next = monhost_child_current;
104
+				monhost_child_current->next = NULL;
105
+				monhost_len++;
106
+
107
+				/* Be sure to not mangle original optarg, nor rely on its longevity */
108
+				s = xstrdup(optarg);
109
+				m_arg = s;
110
+				monhost_child_current->monhost = xstrdup(strsep(&m_arg, ","));
111
+				if (!m_arg)
112
+					fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple");
113
+				monhost_child_current->logfn = xstrdup(strsep(&m_arg, ","));
114
+				if (!m_arg)
115
+					fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple");
116
+				monhost_child_current->pidfilebase = xstrdup(strsep(&m_arg, ","));
117
+				if (m_arg) /* Had a third comma - also unexpected! */
118
+					fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple");
119
+				free(s);
120
+				} /* var scope */
121
+				break;
122
 			case 's':
123
 				monhost = optarg;
124
 				break;
125
@@ -477,6 +540,41 @@
126
 
127
 		for (i = 3; i < argc; i++)
128
 			snprintfcat(logformat, LARGEBUF, "%s ", argv[i]);
129
+	}
130
+
131
+	if (monhost_child_anchor != NULL) {
132
+		if (foreground > 0)
133
+			daemon_pid = 0;
134
+		else
135
+			daemon_pid = fork();
136
+		if (!daemon_pid) {
137
+			upsdebugx(1,"Forking to log %" PRIuSIZE " devices", monhost_len);
138
+			for (monhost_child_current = monhost_child_anchor;
139
+			     monhost_child_current != NULL;
140
+			     monhost_child_current = monhost_child_current->next) {
141
+				if ((monhost_child_current->pid = fork()) == 0) {
142
+					monhost = monhost_child_current->monhost;
143
+					logfn = monhost_child_current->logfn;
144
+					pidfilebase = monhost_child_current->pidfilebase;
145
+					foreground = 1;
146
+					break;
147
+				}
148
+			}
149
+			if (monhost_child_anchor->pid) {	/* parent */
150
+				for (mh = 0; mh < sizeof(trapped_signals)/sizeof(trapped_signals[0]); mh++) {
151
+					upslog_sigaction.sa_handler = &term_handler;
152
+					sigfillset(&upslog_sigaction.sa_mask);
153
+					upslog_sigaction.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT;
154
+					sigaction(trapped_signals[mh], &upslog_sigaction, NULL);
155
+				}
156
+				become_user(get_user_pwent(user));
157
+				writepid(pidfilebase);
158
+				while(wait(&wait_status) > 0);
159
+				exit(EXIT_SUCCESS);
160
+			}
161
+		} else {
162
+			exit(EXIT_SUCCESS);
163
+		}
164
 	}
165
 
166
 	if (!monhost)
(-)b/sysutils/nut-devel/files/patch-docs_man_upslog.txt (+16 lines)
Added Link Here
1
diff --git a/docs/man/upslog.txt b/docs/man/upslog.txt
2
index f4051048..f49695fe 100644
3
--- docs/man/upslog.txt
4
+++ docs/man/upslog.txt
5
@@ -78,6 +78,11 @@ upslog will run in the background, regardless of logging target.
6
 Monitor this UPS.  The format for this option is
7
 +upsname[@hostname[:port]]+.  The default hostname is "localhost".
8
 
9
+*-m* 'tuple'::
10
+Monitor multiple UPSs. The format for this option is a tuple of
11
+ups, logfile, and pidfile separated by commas. An example would be:
12
+`upsname@hostname:9999,/var/log/nut/cps.log,/var/run/cps.pid`
13
+
14
 *-u* 'username'::
15
 
16
 If started as root, upslog will *setuid*(2) to the user id
(-)b/sysutils/nut/Makefile (-1 / +1 lines)
Lines 1-6 Link Here
1
PORTNAME=	nut
1
PORTNAME=	nut
2
PORTVERSION=	2.8.0
2
PORTVERSION=	2.8.0
3
PORTREVISION=	6
3
PORTREVISION=	7
4
CATEGORIES=	sysutils
4
CATEGORIES=	sysutils
5
MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
5
MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
6
6
(-)b/sysutils/nut/files/patch-clients_upslog.c (+166 lines)
Added Link Here
1
--- clients/upslog.c.orig	2022-08-26 08:23:11.123098000 -0700
2
+++ clients/upslog.c	2022-08-26 08:35:02.950760000 -0700
3
@@ -32,6 +32,10 @@
4
  */
5
 
6
 #include "common.h"
7
+#include <signal.h>
8
+#include <unistd.h>
9
+#include <sys/types.h>
10
+#include <sys/wait.h>
11
 #include "nut_platform.h"
12
 #include "upsclient.h"
13
 
14
@@ -41,17 +45,32 @@
15
 #include "upslog.h"
16
 
17
 	static	int	reopen_flag = 0, exit_flag = 0;
18
+	static	int	wait_status;
19
 	static	uint16_t	port;
20
 	static	char	*upsname, *hostname;
21
 	static	UPSCONN_t	ups;
22
 
23
 	static	FILE	*logfile;
24
-	static	const	char *logfn, *monhost;
25
+	static	char *logfn, *monhost;
26
 	static	sigset_t	nut_upslog_sigmask;
27
 	static	char	logbuffer[LARGEBUF], *logformat;
28
 
29
 	static	flist_t	*fhead = NULL;
30
+	struct 	monhost_child {
31
+		char	*monhost;
32
+		char	*logfn;
33
+		char	*pidfilebase;
34
+		pid_t	pid;
35
+		struct	monhost_child	*next;
36
+	};
37
+	static	struct	monhost_child *monhost_child_anchor = NULL;
38
+	static	struct	monhost_child *monhost_child_current = NULL;
39
+	static	struct	monhost_child *monhost_child_prev = NULL;
40
+	static	struct	sigaction upslog_sigaction;
41
+	static	int	trapped_signals[] = { SIGINT, SIGTERM, SIGCHLD };
42
+	static	pid_t	daemon_pid;
43
 
44
+
45
 #define DEFAULT_LOGFORMAT "%TIME @Y@m@d @H@M@S% %VAR battery.charge% " \
46
 		"%VAR input.voltage% %VAR ups.load% [%VAR ups.status%] " \
47
 		"%VAR ups.temperature% %VAR input.frequency%"
48
@@ -131,6 +150,8 @@
49
 	printf("  -p <pidbase>  - Base name for PID file (defaults to \"%s\")\n", prog);
50
 	printf("  -s <ups>	- Monitor UPS <ups> - <upsname>@<host>[:<port>]\n");
51
 	printf("        	- Example: -s myups@server\n");
52
+	printf("  -m <tuple>	- Monitor UPS <ups,logfile,pidfile>,\n");
53
+	printf("		- Example: -m myups@server,/var/log/myups.log,/var/run/myups.pid\n");
54
 	printf("  -u <user>	- Switch to <user> if started as root\n");
55
 
56
 	printf("\n");
57
@@ -393,9 +414,24 @@
58
 	 * -u <username>
59
 	 */
60
 
61
+static void term_handler(int signo)
62
+{
63
+	if (signo != SIGCHLD && monhost_child_anchor != NULL) {
64
+		for (monhost_child_current = monhost_child_anchor;
65
+		     monhost_child_current != NULL;
66
+		     monhost_child_current = monhost_child_current->next
67
+		) {
68
+			kill(monhost_child_current->pid, signo);
69
+		}
70
+
71
+		fatalx(EXIT_FAILURE, "Killed by user");
72
+	}
73
+}
74
+
75
 int main(int argc, char **argv)
76
 {
77
 	int	interval = 30, i, foreground = -1;
78
+	size_t	monhost_len = 0, mh;
79
 	const char	*prog = xbasename(argv[0]);
80
 	time_t	now, nextpoll = 0;
81
 	const char	*user = NULL;
82
@@ -407,7 +443,7 @@
83
 
84
 	printf("Network UPS Tools %s %s\n", prog, UPS_VERSION);
85
 
86
-	while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FB")) != -1) {
87
+	while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FBm:")) != -1) {
88
 		switch(i) {
89
 			case 'h':
90
 				help(prog);
91
@@ -415,6 +451,33 @@
92
 				break;
93
 #endif
94
 
95
+			case 'm': { /* var scope */
96
+				char *m_arg, *s;
97
+
98
+				monhost_child_prev = monhost_child_current;
99
+				monhost_child_current = xmalloc(sizeof(struct monhost_child));
100
+				if (monhost_child_anchor == NULL)
101
+					monhost_child_anchor = monhost_child_current;
102
+				else
103
+					monhost_child_prev->next = monhost_child_current;
104
+				monhost_child_current->next = NULL;
105
+				monhost_len++;
106
+
107
+				/* Be sure to not mangle original optarg, nor rely on its longevity */
108
+				s = xstrdup(optarg);
109
+				m_arg = s;
110
+				monhost_child_current->monhost = xstrdup(strsep(&m_arg, ","));
111
+				if (!m_arg)
112
+					fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple");
113
+				monhost_child_current->logfn = xstrdup(strsep(&m_arg, ","));
114
+				if (!m_arg)
115
+					fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple");
116
+				monhost_child_current->pidfilebase = xstrdup(strsep(&m_arg, ","));
117
+				if (m_arg) /* Had a third comma - also unexpected! */
118
+					fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile,pidfile' requires exactly 3 components in the tuple");
119
+				free(s);
120
+				} /* var scope */
121
+				break;
122
 			case 's':
123
 				monhost = optarg;
124
 				break;
125
@@ -477,6 +540,41 @@
126
 
127
 		for (i = 3; i < argc; i++)
128
 			snprintfcat(logformat, LARGEBUF, "%s ", argv[i]);
129
+	}
130
+
131
+	if (monhost_child_anchor != NULL) {
132
+		if (foreground > 0)
133
+			daemon_pid = 0;
134
+		else
135
+			daemon_pid = fork();
136
+		if (!daemon_pid) {
137
+			upsdebugx(1,"Forking to log %" PRIuSIZE " devices", monhost_len);
138
+			for (monhost_child_current = monhost_child_anchor;
139
+			     monhost_child_current != NULL;
140
+			     monhost_child_current = monhost_child_current->next) {
141
+				if ((monhost_child_current->pid = fork()) == 0) {
142
+					monhost = monhost_child_current->monhost;
143
+					logfn = monhost_child_current->logfn;
144
+					pidfilebase = monhost_child_current->pidfilebase;
145
+					foreground = 1;
146
+					break;
147
+				}
148
+			}
149
+			if (monhost_child_anchor->pid) {	/* parent */
150
+				for (mh = 0; mh < sizeof(trapped_signals)/sizeof(trapped_signals[0]); mh++) {
151
+					upslog_sigaction.sa_handler = &term_handler;
152
+					sigfillset(&upslog_sigaction.sa_mask);
153
+					upslog_sigaction.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT;
154
+					sigaction(trapped_signals[mh], &upslog_sigaction, NULL);
155
+				}
156
+				become_user(get_user_pwent(user));
157
+				writepid(pidfilebase);
158
+				while(wait(&wait_status) > 0);
159
+				exit(EXIT_SUCCESS);
160
+			}
161
+		} else {
162
+			exit(EXIT_SUCCESS);
163
+		}
164
 	}
165
 
166
 	if (!monhost)
(-)b/sysutils/nut/files/patch-docs_man_upslog.8 (+16 lines)
Added Link Here
1
--- docs/man/upslog.8.orig	2022-04-26 15:07:16.000000000 -0700
2
+++ docs/man/upslog.8	2022-08-24 07:39:07.356811000 -0700
3
@@ -134,6 +134,13 @@
4
 upsname[@hostname[:port]]\&. The default hostname is "localhost"\&.
5
 .RE
6
 .PP
7
+\fB\-m\fR \fItuple\fR
8
+.RS 4
9
+Monitor multiple UPSs. The format for this option is a tuple of
10
+ups, logfile, and pidfile separated by commas. An example would be:
11
+`upsname@hostname:9999,/var/log/nut/cps.log,/var/run/cps.pid`
12
+.RE
13
+.PP
14
 \fB\-u\fR \fIusername\fR
15
 .RS 4
16
 If started as root, upslog will
(-)b/sysutils/nut/files/patch-include_nut__stdint.h (-2 / +31 lines)
Added Link Here
0
- 
1
--- include/nut_stdint.h.orig	2022-08-24 07:49:23.934399000 -0700
1
--
2
+++ include/nut_stdint.h	2022-08-24 07:56:48.050406000 -0700
3
@@ -52,6 +52,28 @@
4
 #endif
5
 
6
 /* Printing format for size_t and ssize_t */
7
+#ifndef PRIuSIZE
8
+# ifdef PRIsize
9
+#  define PRIuSIZE PRIsize
10
+# else
11
+#  if defined(__MINGW32__) || defined (WIN32)
12
+#   define PRIuSIZE "llu"
13
+#  else
14
+#   define PRIuSIZE "zu"
15
+#  endif
16
+# endif
17
+#endif
18
+
19
+#ifndef PRIxSIZE
20
+#  if defined(__MINGW32__) || defined (WIN32)
21
+#   define PRIxSIZE "llx"
22
+#  else
23
+#   define PRIxSIZE "zx"
24
+#  endif
25
+#endif
26
+
27
+/* Note: Windows headers are known to define at least "d" values,
28
+ * so macros below revolve around that and not "i" directly */
29
 #ifndef PRIsize
30
 # if defined(__MINGW32__)
31
 #  define PRIsize "u"
2
sysutils/nut-devel/Makefile                |  3 +-
32
sysutils/nut-devel/Makefile                |  3 +-
3
sysutils/nut-devel/files/nut_upslog.sample | 52 ++++++++++++++++++++++
33
sysutils/nut-devel/files/nut_upslog.sample | 52 ++++++++++++++++++++++
4
sysutils/nut-devel/pkg-plist               |  1 +
34
sysutils/nut-devel/pkg-plist               |  1 +
5
sysutils/nut/Makefile                      |  3 +-
35
sysutils/nut/Makefile                      |  3 +-
6
sysutils/nut/files/nut_upslog.sample       | 52 ++++++++++++++++++++++
36
sysutils/nut/files/nut_upslog.sample       | 52 ++++++++++++++++++++++
7
sysutils/nut/pkg-plist                     |  1 +
37
sysutils/nut/pkg-plist                     |  1 +
8
6 files changed, 110 insertions(+), 2 deletions(-)
38
6 files changed, 110 insertions(+), 2 deletions(-)
9
create mode 100644 sysutils/nut-devel/files/nut_upslog.sample
39
create mode 100644 sysutils/nut-devel/files/nut_upslog.sample
10
create mode 100644 sysutils/nut/files/nut_upslog.sample
40
create mode 100644 sysutils/nut/files/nut_upslog.sample
(-)b/sysutils/nut-devel/Makefile (-1 / +2 lines)
Lines 1-6 Link Here
1
PORTNAME=	nut
1
PORTNAME=	nut
2
PORTVERSION=	${NUT_COMMIT_DATE}
2
PORTVERSION=	${NUT_COMMIT_DATE}
3
PORTREVISION=	1
3
PORTREVISION=	2
4
CATEGORIES=	sysutils
4
CATEGORIES=	sysutils
5
PKGNAMESUFFIX=	-devel
5
PKGNAMESUFFIX=	-devel
6
# MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
6
# MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
Lines 164-169 post-install: Link Here
164
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
164
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
165
	${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample
165
	${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample
166
	${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample
166
	${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample
167
	${INSTALL_DATA} ${PATCHDIR}/nut_upslog.sample ${STAGEDIR}${EXAMPLESDIR}/nut_upslog.sample
167
	${MKDIR} ${STAGEDIR}/var/log/nut
168
	${MKDIR} ${STAGEDIR}/var/log/nut
168
169
169
.include <bsd.port.post.mk>
170
.include <bsd.port.post.mk>
(-)b/sysutils/nut-devel/files/nut_upslog.sample (+52 lines)
Added Link Here
1
#!/bin/sh
2
3
# Authored by vvd@unislabs.com.
4
5
# PROVIDE: nut_upslog
6
# REQUIRE: NETWORKING nut
7
# BEFORE: LOGIN
8
# KEYWORD: shutdown
9
10
. /etc/rc.subr
11
12
case $0 in
13
/etc/rc*)
14
	# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
15
	# so get the name of the script from $_file
16
	name=$_file
17
	;;
18
*)
19
	name=$0
20
	;;
21
esac
22
23
name=${name##*/}
24
rcvar=${name}_enable
25
26
load_rc_config "${name}"
27
28
# Define these nut_upslog* variables in one of these files:
29
#       /etc/rc.conf
30
#       /etc/rc.conf.local
31
#       /etc/rc.conf.d/nut_upslog
32
#
33
# If you want to log several different UPSes:
34
# ln -s nut_upslog /usr/local/etc/rc.d/NAME
35
# then set variables NAME_enable, NAME_ups, NAME_pidbase, NAME_logfile and etc.
36
#
37
# DO NOT CHANGE THESE DEFAULT VALUES HERE
38
#
39
eval "${rcvar}=\${${rcvar}:-'NO'}"
40
eval "_prefix=\${${name}_prefix:-'/usr/local'}"
41
eval "_logfile=\${${name}_logfile:-'/var/log/nut/ups.log'}"
42
eval "_interval=\${${name}_interval:-'300'}"
43
eval "_ups=\${${name}_ups:-'myups@localhost'}"
44
eval "_pidbase=\${${name}_pidbase:-'upslog'}"
45
eval "_format=\${${name}_format:+-f \${${name}_format}}"
46
eval "${name}_flags=\${${name}_flags:-'-s ${_ups} -l ${_logfile} -i ${_interval} -p ${_pidbase} ${_format}'}"
47
48
required_dirs="%%STATEDIR%%"
49
pidfile="%%STATEDIR%%/${_pidbase}.pid"
50
command="${_prefix}/bin/upslog"
51
52
run_rc_command "$1"
(-)b/sysutils/nut-devel/pkg-plist (+1 lines)
Lines 18-23 Link Here
18
@sample %%ETCDIR%%/upsmon.conf.sample
18
@sample %%ETCDIR%%/upsmon.conf.sample
19
@sample %%ETCDIR%%/upssched.conf.sample
19
@sample %%ETCDIR%%/upssched.conf.sample
20
@sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf
20
@sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf
21
@sample %%EXAMPLESDIR%%/nut_upslog.sample
21
@sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut
22
@sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut
22
%%USB%%etc/devd/nut-usb.conf
23
%%USB%%etc/devd/nut-usb.conf
23
bin/nut-scanner
24
bin/nut-scanner
(-)b/sysutils/nut/Makefile (-1 / +2 lines)
Lines 1-6 Link Here
1
PORTNAME=	nut
1
PORTNAME=	nut
2
PORTVERSION=	2.8.0
2
PORTVERSION=	2.8.0
3
PORTREVISION=	7
3
PORTREVISION=	8
4
CATEGORIES=	sysutils
4
CATEGORIES=	sysutils
5
MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
5
MASTER_SITES=	http://www.networkupstools.org/source/${PORTVERSION:R}/
6
6
Lines 142-147 post-install: Link Here
142
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
142
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
143
	${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample
143
	${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample
144
	${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample
144
	${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample
145
	${INSTALL_DATA} ${PATCHDIR}/nut_upslog.sample ${STAGEDIR}${EXAMPLESDIR}/nut_upslog.sample
145
	${MKDIR} ${STAGEDIR}/var/log/nut
146
	${MKDIR} ${STAGEDIR}/var/log/nut
146
	@${RM} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init/nut
147
	@${RM} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init/nut
147
	@${RMDIR} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init
148
	@${RMDIR} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init
(-)b/sysutils/nut/files/nut_upslog.sample (+52 lines)
Added Link Here
1
#!/bin/sh
2
3
# Authored by vvd@unislabs.com.
4
5
# PROVIDE: nut_upslog
6
# REQUIRE: NETWORKING nut
7
# BEFORE: LOGIN
8
# KEYWORD: shutdown
9
10
. /etc/rc.subr
11
12
case $0 in
13
/etc/rc*)
14
	# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
15
	# so get the name of the script from $_file
16
	name=$_file
17
	;;
18
*)
19
	name=$0
20
	;;
21
esac
22
23
name=${name##*/}
24
rcvar=${name}_enable
25
26
load_rc_config "${name}"
27
28
# Define these nut_upslog* variables in one of these files:
29
#       /etc/rc.conf
30
#       /etc/rc.conf.local
31
#       /etc/rc.conf.d/nut_upslog
32
#
33
# If you want to log several different UPSes:
34
# ln -s nut_upslog /usr/local/etc/rc.d/NAME
35
# then set variables NAME_enable, NAME_ups, NAME_pidbase, NAME_logfile and etc.
36
#
37
# DO NOT CHANGE THESE DEFAULT VALUES HERE
38
#
39
eval "${rcvar}=\${${rcvar}:-'NO'}"
40
eval "_prefix=\${${name}_prefix:-'/usr/local'}"
41
eval "_logfile=\${${name}_logfile:-'/var/log/nut/ups.log'}"
42
eval "_interval=\${${name}_interval:-'300'}"
43
eval "_ups=\${${name}_ups:-'myups@localhost'}"
44
eval "_pidbase=\${${name}_pidbase:-'upslog'}"
45
eval "_format=\${${name}_format:+-f \${${name}_format}}"
46
eval "${name}_flags=\${${name}_flags:-'-s ${_ups} -l ${_logfile} -i ${_interval} -p ${_pidbase} ${_format}'}"
47
48
required_dirs="%%STATEDIR%%"
49
pidfile="%%STATEDIR%%/${_pidbase}.pid"
50
command="${_prefix}/bin/upslog"
51
52
run_rc_command "$1"
(-)b/sysutils/nut/pkg-plist (-1 / +1 lines)
Lines 18-23 Link Here
18
@sample %%ETCDIR%%/upsmon.conf.sample
18
@sample %%ETCDIR%%/upsmon.conf.sample
19
@sample %%ETCDIR%%/upssched.conf.sample
19
@sample %%ETCDIR%%/upssched.conf.sample
20
@sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf
20
@sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf
21
@sample %%EXAMPLESDIR%%/nut_upslog.sample
21
@sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut
22
@sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut
22
%%USB%%etc/devd/nut-usb.conf
23
%%USB%%etc/devd/nut-usb.conf
23
bin/nut-scanner
24
bin/nut-scanner
24
- 

Return to bug 265963