ALT Linux repositórios
Group :: Sistema/Servidores
RPM: nut
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: nut-2.8.0-alt-upsdrvctl-list.patch
Download
Download
From 2a6f0026d3a4f8cd92b2207bed46c4c522c28fc6 Mon Sep 17 00:00:00 2001
From: Elizaveta Morozova <morozovaes@altlinux.org>
Date: Thu, 2 Mar 2023 10:32:17 +0300
Subject: [PATCH] nut-2.8.0-alt-upsdrvctl-list
---
drivers/upsdrvctl.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/upsdrvctl.c b/drivers/upsdrvctl.c
index a33fcd159..35abc82ca 100644
--- a/drivers/upsdrvctl.c
+++ b/drivers/upsdrvctl.c
@@ -397,13 +397,28 @@ static void start_driver(const ups_t *ups)
}
}
+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)
__attribute__((noreturn));
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");
@@ -411,6 +426,8 @@ static void help(const char *progname)
printf(" -u <user> drivers started will switch from root to <user>\n");
printf(" -D raise debugging level\n");
printf(" -d pass debugging level from upsdrvctl to driver\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");
@@ -595,6 +612,9 @@ int main(int argc, char **argv)
"pass its current debug level to the launched driver.\n");
}
+ if (!strcmp(argv[0], "list"))
+ command = &list_driver;
+
if (!strcmp(argv[0], "start"))
command = &start_driver;
--
2.33.5