diff --git a/drivers/main.c b/drivers/main.c index 63d329b7c..3d955de64 100644 --- a/drivers/main.c +++ b/drivers/main.c @@ -847,6 +847,19 @@ int main(int argc, char **argv) } upsdebugx(1, "debug level is '%d'", nut_debug_level); + upsdrv_initups(); + + /* UPS is detected now, cleanup upon exit */ + atexit(upsdrv_cleanup); + + /* now see if things are very wrong out there */ + if (upsdrv_info.status == DRV_BROKEN) { + fatalx(EXIT_FAILURE, "Fatal error: broken driver. It probably needs to be converted.\n"); + } + + if (do_forceshutdown) + forceshutdown(); + new_uid = get_user_pwent(user); if (chroot_path) @@ -904,19 +917,6 @@ int main(int argc, char **argv) * when its a pdu! */ dstate_setinfo("device.type", "ups"); - upsdrv_initups(); - - /* UPS is detected now, cleanup upon exit */ - atexit(upsdrv_cleanup); - - /* now see if things are very wrong out there */ - if (upsdrv_info.status == DRV_BROKEN) { - fatalx(EXIT_FAILURE, "Fatal error: broken driver. It probably needs to be converted.\n"); - } - - if (do_forceshutdown) - forceshutdown(); - /* publish the top-level data: version numbers, driver name */ dstate_setinfo("driver.version", "%s", UPS_VERSION); dstate_setinfo("driver.version.internal", "%s", upsdrv_info.version); -- 2.33.5