Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37812135
en ru br
ALT Linux repositórios
S:2.8.0-alt2
5.0: 2.0.5-alt3.1
4.1: 2.0.5-alt3
4.0: 2.0.5-alt2
3.0: 2.0.2-alt1

Group :: Sistema/Servidores
RPM: nut

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: nut-2.6.0-alt-upsdrvctl-list.patch
Download


diff -U 3 -r nut-2.6.0.orig/drivers/upsdrvctl.c nut-2.6.0/drivers/upsdrvctl.c
--- nut-2.6.0.orig/drivers/upsdrvctl.c	2011-02-08 12:35:02 +0200
+++ nut-2.6.0/drivers/upsdrvctl.c	2011-02-08 12:40:38 +0200
@@ -283,16 +283,33 @@
 	}
 }
 
+static void list_driver(const ups_t *ups)
+{
+	char    dfn[SMALLBUF];
+	int     ret;
+	struct  stat    fs;
+	
+	snprintf(dfn, sizeof(dfn), "%s/%s", driverpath, ups->driver);
+	ret = stat(dfn, &fs);
+	
+	if (ret < 0)
+		upslogx(LOG_ERR, "stat: %s: %m", dfn);
+	else
+		puts(dfn);
+}
+
 static void help(const char *progname)
 {
 	printf("Starts and stops UPS drivers via ups.conf.\n\n");
-	printf("usage: %s [OPTIONS] (start | stop | shutdown) [<ups>]\n\n", progname);
+	printf("usage: %s [OPTIONS] (list | start | stop | shutdown) [<ups>]\n\n", progname);
 
 	printf("  -h			display this help\n");
 	printf("  -r <path>		drivers will chroot to <path>\n");
 	printf("  -t			testing mode - prints actions without doing them\n");
 	printf("  -u <user>		drivers started will switch from root to <user>\n");
 	printf("  -D            	raise debugging level\n");
+ 	printf("  list			list all UPS drivers in ups.conf\n");
+	printf("  list	<ups>		only list driver for UPS <ups>\n");
 	printf("  start			start all UPS drivers in ups.conf\n");
 	printf("  start	<ups>		only start driver for UPS <ups>\n");
 	printf("  stop			stop all UPS drivers in ups.conf\n");
@@ -470,6 +487,10 @@
 		   "starts and you need to copy and paste that line and append the debug flags to that\n"
 		   "line (less the 'exec:' prefix).\n");
 
+
+	if (!strcmp(argv[0], "list"))
+		command = &list_driver;
+
 	if (!strcmp(argv[0], "start"))
 		command = &start_driver;
 
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009