|
|
@@ -70,6 +70,7 @@ print_system_resources(void) |
|
|
#define ACTION_LIST 0x02
|
|
|
#define ACTION_SUPPORTED 0x04
|
|
|
#define ACTION_INFO 0x08
|
|
|
+#define ACTION_ENABLE 0x10
|
|
|
|
|
|
int
|
|
|
main(int argc, char *argv[]) {
|
|
|
@@ -114,6 +115,12 @@ main(int argc, char *argv[]) { |
|
|
.val = ACTION_INFO,
|
|
|
.descrip =
|
|
|
_("Show the information of firmware update status")},
|
|
|
+ {.longName = "enable",
|
|
|
+ .shortName = 'e',
|
|
|
+ .argInfo = POPT_ARG_VAL|POPT_ARGFLAG_OR,
|
|
|
+ .arg = &action,
|
|
|
+ .val = ACTION_ENABLE,
|
|
|
+ .descrip = _("Enable firmware update support on supported systems (will require a reboot)") },
|
|
|
{.longName = "quiet",
|
|
|
.shortName = 'q',
|
|
|
.argInfo = POPT_ARG_VAL,
|
|
|
@@ -183,6 +190,15 @@ main(int argc, char *argv[]) { |
|
|
if (!quiet)
|
|
|
printf("%s", _("Firmware updates are supported on this machine.\n"));
|
|
|
return 0;
|
|
|
+ } else if (rc == 2) {
|
|
|
+ if (!quiet)
|
|
|
+ printf("%s", _("Firmware updates are supported on this machine, but currently disabled.\n"));
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ else if (rc == 3) {
|
|
|
+ if (!quiet)
|
|
|
+ printf("%s", _("Firmware updates are supported on this machine, and will be enabled on the next reboot.\n"));
|
|
|
+ return 2;
|
|
|
}
|
|
|
} else if (action & ACTION_LIST) {
|
|
|
rc = print_system_resources();
|
|
|
@@ -224,6 +240,26 @@ main(int argc, char *argv[]) { |
|
|
if (rc < 0)
|
|
|
errx(6, _("Could not display firmware update status"));
|
|
|
return 0;
|
|
|
+ } else if (action & ACTION_ENABLE) {
|
|
|
+ if (geteuid() != 0) {
|
|
|
+ if (!quiet)
|
|
|
+ printf("%s", _("To enable firmware updates, this tool must be launched as root.\n"));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ rc = enable_esrt();
|
|
|
+ if (rc < 1) {
|
|
|
+ if (!quiet)
|
|
|
+ printf("%s", _("Firmware updates can not be enabled on this machine from this tool.\n"));
|
|
|
+ return 1;
|
|
|
+ } else if (rc == 1) {
|
|
|
+ if (!quiet)
|
|
|
+ printf("%s", _("Firmware updates are already enabled.\n"));
|
|
|
+ return 1;
|
|
|
+ } else if (rc == 2 || rc == 3) {
|
|
|
+ if (!quiet)
|
|
|
+ printf("%s", _("Firmware updates will be enabled after the system is rebooted.\n"));
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
0 comments on commit
3b08a16