Skip to content

Can't shutdown automatically, Fedora 42 KDE, SELinux enforcing, Prolink PRO1201SFCU 1200VA #3230

@Onxr

Description

@Onxr

Host: Fedora 42 KDE
UPS: Prolink PRO1201SFCU 1200VA
SELinux enabled
Host doesn't shutdown automatically. I don't know what to do. I have followed many guides and was able to do these.

/etc/ups contents

$ ls -l /etc/ups
total 108
-rw-r-----. 1 root nut   142 Dec 19 17:57 nut.conf
-rw-r-----. 1 root nut  9105 Aug  6 19:50 nut-example.conf
-rw-r-----. 1 root nut   276 Dec 20 00:03 ups.conf
-rw-r-----. 1 root nut   242 Dec 19 18:07 upsd.conf
-rw-r-----. 1 root nut  9566 Apr 19  2025 upsd-example.conf
-rw-r-----. 1 root nut  2476 Apr 19  2025 upsd-example.users
-rw-r-----. 1 root nut    47 Dec 21 18:36 upsd.users
-rw-r-----. 1 root nut 11847 Apr 19  2025 ups-example.conf
-rw-r-----. 1 root nut  3467 Dec 21 18:37 upsmon.conf
-rw-r-----. 1 root nut 30718 Aug 14 06:00 upsmon-example.conf
-rwxr-x--x. 1 root nut   994 Dec 21 19:13 upssched-cmd
-rw-r-----. 1 root nut   783 Dec 21 20:48 upssched.conf
-rw-r-----. 1 root nut  4332 Aug 14 06:00 upssched-example.conf


$ ls -lZ /etc/ups
total 108
-rw-r-----. 1 root nut unconfined_u:object_r:nut_conf_t:s0   142 Dec 19 17:57 nut.conf
-rw-r-----. 1 root nut system_u:object_r:nut_conf_t:s0      9105 Aug  6 19:50 nut-example.conf
-rw-r-----. 1 root nut unconfined_u:object_r:nut_conf_t:s0   276 Dec 20 00:03 ups.conf
-rw-r-----. 1 root nut unconfined_u:object_r:nut_conf_t:s0   242 Dec 19 18:07 upsd.conf
-rw-r-----. 1 root nut system_u:object_r:nut_conf_t:s0      9566 Apr 19  2025 upsd-example.conf
-rw-r-----. 1 root nut system_u:object_r:nut_conf_t:s0      2476 Apr 19  2025 upsd-example.users
-rw-r-----. 1 root nut unconfined_u:object_r:nut_conf_t:s0    47 Dec 21 18:36 upsd.users
-rw-r-----. 1 root nut system_u:object_r:nut_conf_t:s0     11847 Apr 19  2025 ups-example.conf
-rw-r-----. 1 root nut unconfined_u:object_r:nut_conf_t:s0  3467 Dec 21 18:37 upsmon.conf
-rw-r-----. 1 root nut system_u:object_r:nut_conf_t:s0     30718 Aug 14 06:00 upsmon-example.conf
-rwxr-x--x. 1 root nut unconfined_u:object_r:nut_conf_t:s0   994 Dec 21 19:13 upssched-cmd
-rw-r-----. 1 root nut unconfined_u:object_r:nut_conf_t:s0   783 Dec 21 20:48 upssched.conf
-rw-r-----. 1 root nut system_u:object_r:nut_conf_t:s0      4332 Aug 14 06:00 upssched-example.conf
# ups.conf
# How often will poll
pollinterval = 1
# Max retry before deemed failed
maxretry = 3

# UPS specific driver
# Get info using: sudo nut-scanner -U
[prolink]
    driver = nutdrv_qx
    port = auto
    desc = "Prolink PRO1201SFCU 1200VA"
    vendorid = 0665
    productid = 5161
# upsd.conf
# Use only one method
# REMEMBER: comment out the other one
# ----------------------------------------
# Use as standalone. Listens only localhost
LISTEN 127.0.0.1 3493

# Use as Server/Client. Listens all IP addresses
# LISTEN 0.0.0.0 3493
# upsd.users
[monuser]
  password = secret
  upsmon primary
# upsmon.conf
# You can setup additional account with restriction 
# Running as root is simpler method
RUN_AS_USER root

# Monitor UPS one line/entry for each UPS
# MONITOR devicename@host <how many ups are connected to this device> <account> <password> <type (use master if UPS is connected to this device else slave)>
MONITOR prolink@localhost 1 monuser secret primary



# Min UPS requires to be alive
MINSUPPLIES 1
# Shutdown command binary
SHUTDOWNCMD "/sbin/shutdown -h"
# Notification command binary
NOTIFYCMD /usr/sbin/upssched
POLLFREQ 2
POLLFREQALERT 1
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower



# NOTIFYMSG - change messages sent by upsmon when certain events occur
# --------------------------------------------------------------------------
# You can change the default messages to something else if you like.
# NOTIFYMSG <notify type> "message"
# Note that %s (where used) is replaced with the identifier of the UPS in question.

# Meanings of some possible values for <notify type>:
#
# ONLINE   : UPS is back online
# ONBATT   : UPS is on battery
# LOWBATT  : UPS has a low battery (if also on battery, it's "critical")
# FSD      : UPS is being shutdown by the primary (FSD = "Forced Shutdown")
# COMMOK   : Communications established with the UPS
# COMMBAD  : Communications lost to the UPS
# SHUTDOWN : The system is being shutdown
# REPLBATT : The UPS battery is bad and needs to be replaced
# NOCOMM   : A UPS is unavailable (can't be contacted for monitoring)
# NOPARENT : The process that shuts down the system has died (shutdown impossible)
# ALARM    : UPS has one or more alarms (look at "ups.alarm" for details)

NOTIFYMSG ONLINE    "UPS %s on line power"
NOTIFYMSG ONBATT    "UPS %s on battery"
NOTIFYMSG LOWBATT   "UPS %s battery is low"
NOTIFYMSG FSD       "UPS %s: forced shutdown in progress"
NOTIFYMSG COMMOK    "Communications with UPS %s established"
NOTIFYMSG COMMBAD   "Communications with UPS %s lost"
NOTIFYMSG SHUTDOWN  "Auto logout and shutdown proceeding"
NOTIFYMSG REPLBATT  "UPS %s battery needs to be replaced"
NOTIFYMSG NOCOMM    "UPS %s is unavailable"
NOTIFYMSG NOPARENT  "upsmon parent process died - shutdown impossible"

# NOTIFYFLAG - change behavior of upsmon when NOTIFY events occur
# --------------------------------------------------------------------------
# By default, upsmon sends walls (global messages to all logged in users)
# and writes to the syslog when things happen.
# Except for Windows where upsmon only writes to the syslog by default.
# You can change this.
#
# NOTIFYFLAG <notify type> <flag>[+<flag>][+<flag>] ...

# Possible values for the flags:
# SYSLOG - Write the message in the syslog
# WALL   - Write the message to all users on the system
# EXEC   - Execute NOTIFYCMD (see above) with the message
# IGNORE - Don't do anything
#
# If you use IGNORE, don't use any other flags on the same line.


NOTIFYFLAG ONLINE   SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT   SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT  SYSLOG+WALL
NOTIFYFLAG FSD      SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK   SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD  SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL
NOTIFYFLAG NOCOMM   SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL

# RBWARNTIME - replace battery warning time in seconds
RBWARNTIME 43200

# NOCOMMWARNTIME - no communications warning time in seconds
NOCOMMWARNTIME 600

# FINALDELAY - last sleep interval before shutting down the system
FINALDELAY 5
# upssched.conf
# You DO HAVE TO create the script
CMDSCRIPT /etc/ups/upssched-cmd

# Command pipe and lock-file
PIPEFN /etc/ups/upssched.pipe
LOCKFN /etc/ups/upssched.lock

#================================================#
# Log running on battery
AT ONBATT * EXECUTE onbatt

# Initiate / cancel shutdown timer
# AT ONBATT * START-TIMER shutdown_timer 150
AT ONBATT * START-TIMER shutdown_timer 30
AT ONLINE * CANCEL-TIMER shutdown_timer

# Critical shutdown when low battery
AT LOWBATT * EXECUTE shutdown_critical

# Start / stop timer on communicaion failure / restoration
AT COMMBAD * START-TIMER commbad_timer 45
AT COMMOK * CANCEL-TIMER commbad_timer

# Notify cant communicate with the UPS
AT NOCOMM * EXECUTE upsgone

# Executes powerdown on system shutdown
AT SHUTDOWN * EXECUTE powerdown
# upssched-cmd
#!/bin/sh
case $1 in
    onbatt)
        # Log the event
        logger -t upssched-cmd "UPS running on battery. Shutting down in 2m 30s"
        ;;
    shutdown_timer)
        # Log the event and initiate a controlled shutdown
        logger -t upssched-cmd "UPS running on battery for too long, initiating shutdown"
        /usr/sbin/upsmon -c fsd
        ;;
    shutdown_critical)
        logger -t upssched-cmd "UPS on battery critical, forced shutdown"
        /usr/sbin/upsmon -c fsd
        ;;
    commbad_timer)
        # Log persistent communication failures and initiate shutdown
        logger -t upssched-cmd "UPS communication failure persists, initiating shutdown"
        ;;
    upsgone)
        logger -t upssched-cmd "UPS has been gone too long, unable to communicate"
        ;;
    *)
        # Log unknown commands
        logger -t upssched-cmd "Unrecognized command: $1"
        ;;
esac

The followings I had to take help from LLM to get passed SELinux issue

sudo ausearch -c 'upsmon' --raw | audit2allow -M upsmon_dac
sudo semodule -i upsmon_dac.pp

sudo ausearch -c 'sh' --raw | sudo audit2allow -M nut_upssched
sudo semodule -i nut_upssched.pp

sudo ausearch -c 'sh' --raw | sudo audit2allow -M nut_upssched_no_trans
sudo semodule -i nut_upssched_no_trans.pp

Here are the *.te files content

module upsmon_dac 1.0;

require {
	type nut_upsmon_t;
	class capability dac_override;
}

#============= nut_upsmon_t ==============
allow nut_upsmon_t self:capability dac_override;
module nut_upssched 1.0;

require {
	type nut_conf_t;
	type nut_upsmon_t;
	class file execute;
}

#============= nut_upsmon_t ==============
allow nut_upsmon_t nut_conf_t:file execute;
module nut_upssched_no_trans 1.0;

require {
	type nut_upsmon_t;
	type nut_conf_t;
	class file { execute execute_no_trans };
}

#============= nut_upsmon_t ==============

#!!!! This avc is allowed in the current policy
allow nut_upsmon_t nut_conf_t:file execute;
allow nut_upsmon_t nut_conf_t:file execute_no_trans;
$ sudo journalctl -t upssched-cmd
[sudo] password for user:
Dec 21 19:14:25 fedora upssched-cmd[21641]: UPS scheduler script testing.
-- Boot f751874da77d48879b3040f0fe7c725e --
Dec 21 19:54:22 fedora upssched-cmd[3934]: UPS running on battery. Shutting down in 2m 30s
-- Boot 04725c6cf64b42b7befad2322ae0e86c --
Dec 21 20:50:37 fedora upssched-cmd[3752]: UPS running on battery. Shutting down in 2m 30s
Dec 21 21:18:12 fedora upssched-cmd[17399]: UPS running on battery for too long, initiating shutdown
Dec 21 21:18:14 fedora upssched-cmd[17438]: Unrecognized command: powerdown

Here I ran manually

  • Dec 21 19:14:25 fedora upssched-cmd[21641] To check if I can execute the script
  • Dec 21 21:18:12 fedora upssched-cmd[17399] To check shutdown_timer argument actually work.
    • It did but took over a minute.
    • At first I got a wall msg. It was there for a while (BTW I did close all the apps window).
    • Then I guess plasmashell was closed, I was getting a blackscreen and some texts (felt like tty)
    • PC shutdown but I cant remember but within less than 10sec I guess my PSU turned itself off. I cant say what triggered that
    • Others triggered automatically

nut-driver-enumerator.path

$ sudo systemctl status nut-driver-enumerator.path
● nut-driver-enumerator.path - Network UPS Tools - Trigger restart of nut-driver-enumerator.service whenever ups.conf is edited
     Loaded: loaded (/usr/lib/systemd/system/nut-driver-enumerator.path; enabled; preset: disabled)
     Active: active (waiting) since Sun 2025-12-21 21:21:05 +06; 26min ago
 Invocation: 0aef19f1af2040a0aa3273591d78065f
   Triggers: ● nut-driver-enumerator.service
       Docs: man:nut-driver-enumerator(8)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/nut-driver-enumerator.html
             man:ups.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/ups.conf.html
             man:upsdrvsvcctl(8)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsdrvsvcctl.html
             man:nut.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/nut.conf.html

Dec 21 21:21:05 fedora systemd[1]: Started nut-driver-enumerator.path - Network UPS Tools - Trigger restart of nut-driver-enumerator.service whenever ups.conf is edited.

nut-driver-enumerator.service

$ sudo systemctl status nut-driver-enumerator.service
○ nut-driver-enumerator.service - Network UPS Tools - enumeration of configure-file devices into systemd unit instances
     Loaded: loaded (/usr/lib/systemd/system/nut-driver-enumerator.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: inactive (dead) since Sun 2025-12-21 21:21:05 +06; 27min ago
 Invocation: 627882e0ad3f4584b37aa66981203ace
TriggeredBy: ● nut-driver-enumerator.path
       Docs: man:nut-driver-enumerator(8)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/nut-driver-enumerator.html
             man:ups.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/ups.conf.html
             man:upsdrvsvcctl(8)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsdrvsvcctl.html
             man:nut.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/nut.conf.html
    Process: 989 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
    Process: 1021 ExecStart=/usr/libexec/nut-driver-enumerator.sh (code=exited, status=0/SUCCESS)
   Main PID: 1021 (code=exited, status=0/SUCCESS)
   Mem peak: 8.2M
        CPU: 77ms

Dec 21 21:21:05 fedora systemd[1]: Starting nut-driver-enumerator.service - Network UPS Tools - enumeration of configure-file devices into systemd unit instances...
Dec 21 21:21:05 fedora nut-driver-enumerator[1021]: Sun 21 Dec 15:21:05 UTC 2025 : OK: No changes to reconcile between systemd service instances and device configurations in '/etc/ups/ups.conf'
Dec 21 21:21:05 fedora systemd[1]: nut-driver-enumerator.service: Deactivated successfully.
Dec 21 21:21:05 fedora systemd[1]: Finished nut-driver-enumerator.service - Network UPS Tools - enumeration of configure-file devices into systemd unit instances.

nut-server.service

$ sudo systemctl status nut-server.service
● nut-server.service - Network UPS Tools - power devices information server
     Loaded: loaded (/usr/lib/systemd/system/nut-server.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Sun 2025-12-21 21:21:07 +06; 28min ago
 Invocation: 0ba16f01365a442aa57f4c374dcd2b24
       Docs: man:upsd(8)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsd.html
             man:ups.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/ups.conf.html
             man:upsd.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsd.conf.html
             man:upsd.users(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsd.users.html
             man:nut.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/nut.conf.html
    Process: 1369 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
    Process: 1372 ExecStartPost=/bin/grep -E Units|Max open files /proc/${MAINPID}/limits (code=exited, status=0/SUCCESS)
   Main PID: 1371 (upsd)
      Tasks: 1 (limit: 18881)
     Memory: 1M (peak: 3.7M)
        CPU: 162ms
     CGroup: /system.slice/nut-server.service
             └─1371 /usr/bin/upsd -F

Dec 21 21:21:07 fedora nut-server[1371]: Running as foreground process, not saving a PID file
Dec 21 21:21:07 fedora nut-server[1371]: upsnotify: notify about state NOTIFY_STATE_READY_WITH_PID with libsystemd: was requested, but not running as a service unit now, will not spam more about it
Dec 21 21:21:07 fedora nut-server[1371]: upsnotify: failed to notify about state NOTIFY_STATE_READY_WITH_PID: no notification tech defined, will not spam more about it
Dec 21 21:21:07 fedora nut-server[1371]: upsnotify: logged the systemd watchdog situation once, will not spam more about it
Dec 21 21:21:07 fedora upsd[1371]: Running as foreground process, not saving a PID file
Dec 21 21:21:07 fedora upsd[1371]: upsnotify: notify about state NOTIFY_STATE_READY_WITH_PID with libsystemd: was requested, but not running as a service unit now, will not spam more about it
Dec 21 21:21:07 fedora upsd[1371]: upsnotify: failed to notify about state NOTIFY_STATE_READY_WITH_PID: no notification tech defined, will not spam more about it
Dec 21 21:21:07 fedora upsd[1371]: upsnotify: logged the systemd watchdog situation once, will not spam more about it
Dec 21 21:21:07 fedora nut-server[1371]: User [email protected] logged into UPS [prolink]
Dec 21 21:21:07 fedora upsd[1371]: User [email protected] logged into UPS [prolink]

nut-monitor.service

$ sudo systemctl status nut-monitor.service
● nut-monitor.service - Network UPS Tools - power device monitor and shutdown controller
     Loaded: loaded (/usr/lib/systemd/system/nut-monitor.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/service.d
             └─10-timeout-abort.conf
     Active: active (running) since Sun 2025-12-21 21:21:07 +06; 29min ago
 Invocation: e9d42d9eebc14f3ca5ae0dcca740850d
       Docs: man:upsmon(8)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsmon.html
             man:upsmon.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/upsmon.conf.html
             man:nut.conf(5)
             https://www.networkupstools.org/historic/v2.8.4/docs/man/nut.conf.html
    Process: 1374 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-common-tmpfiles.conf (code=exited, status=0/SUCCESS)
   Main PID: 1376 (upsmon)
      Tasks: 2 (limit: 18881)
     Memory: 1.7M (peak: 3.7M)
        CPU: 212ms
     CGroup: /system.slice/nut-monitor.service
             ├─1376 /usr/bin/upsmon -F
             └─1377 /usr/bin/upsmon -F

Dec 21 21:21:07 fedora nut-monitor[1376]: Network UPS Tools upsmon 2.8.4 release
Dec 21 21:21:07 fedora nut-monitor[1376]: UPS: prolink@localhost (primary) (power value 1)
Dec 21 21:21:07 fedora nut-monitor[1376]: Using power down flag file /etc/killpower
Dec 21 21:21:07 fedora nut-monitor[1377]: upsnotify: notify about state NOTIFY_STATE_READY_WITH_PID with libsystemd: was requested, but not running as a service unit now, will not spam more about it
Dec 21 21:21:07 fedora nut-monitor[1377]: upsnotify: failed to notify about state NOTIFY_STATE_READY_WITH_PID: no notification tech defined, will not spam more about it
Dec 21 21:21:07 fedora nut-monitor[1377]: upsmon: initialized OS integration for sleep inhibitor
Dec 21 21:21:07 fedora nut-monitor[1377]: upsmon: initialized OS integration for sleep/wake monitoring
Dec 21 21:21:07 fedora nut-monitor[1377]: upsnotify: logged the systemd watchdog situation once, will not spam more about it
Dec 21 21:21:07 fedora nut-monitor[1377]: UPS prolink@localhost: has at least one unclassified status token: [WAIT]
Dec 21 21:21:12 fedora nut-monitor[1377]: UPS prolink@localhost has no unclassified status tokens anymore

I want the PC to turn off itself after 2m30s but for now I wanna test 30s. I am not sure about UPS turning off itself, is it NUT ? or I have a faulty UPS ? From netgate source I can see there's an option about enabling/disabling beeping. Though I haven't tried that, does it mean NUT can shutdown UPS too?
Sorry I am new to these. I am trying my best to understand and fix it. Also is it possible to trigger different state for testing ?

If other information is required do tell me. I tried share everything I know here.

I followed these sources and used LLM for SELinux issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxSome issues are specific to Linux as a platformRedHat Linux ecosystemRHEL, CentOS, Fedora, Rocky Linux, Oracle Linux... (RPM packaging)Shutdowns and overrides and battery level triggersIssues and PRs about system shutdown, especially if battery charge/runtime remaining is involvedimpacts-release-2.8.4Issues reported against NUT release 2.8.4 (maybe vanilla or with minor packaging tweaks)questionupsmonupsschedQuestions and issues about upssched (timer helper for upsmon)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions