ALT Linux repositórios
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
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;