How to get UPS Monitor Daemon to start on Boot

I am trying to get the UPS Monitoring Daemon to start at boot using the Services Manager (YAST) but have failed.
I am running Leap 15.4 KDE. I see the following

After Boot

* pwrstatd.service - The monitor UPS software.
     Loaded: loaded (/etc/systemd/system/pwrstatd.service; disabled; vendor preset: disabled)
     Active: inactive (dead)

After Manually Starting the Daemon

* pwrstatd.service - The monitor UPS software.
     Loaded: loaded (/etc/systemd/system/pwrstatd.service; disabled; vendor preset: disabled)
     Active: active (running) since Sun 2023-02-26 13:42:41 MST; 47s ago
    Process: 12185 ExecStart=/etc/init.d/pwrstatd start (code=exited, status=0/SUCCESS)
   Main PID: 12192 (pwrstatd)
      Tasks: 1 (limit: 4915)
     CGroup: /system.slice/pwrstatd.service
             `- 12192 /usr/sbin/pwrstatd

Feb 26 13:42:41 localhost.heavy1 systemd[1]: Starting The monitor UPS software....
Feb 26 13:42:41 localhost.heavy1 pwrstatd[12185]: Starting pwrstatd 1.4.1..done
Feb 26 13:42:41 localhost.heavy1 systemd[1]: Started The monitor UPS software..

Running status

freda@localhost.heavy1] ~ $ 00pwrstat status

The UPS information shows as following:

        Properties:
                Model Name................... CP1500PFCLCD
                Firmware Number.............. CR01002H8S1
                Rating Voltage............... 120 V
                Rating Power................. 900 Watt

        Current UPS status:
                State........................ Normal
                Power Supply by.............. Utility Power
                Utility Voltage.............. 125 V
                Output Voltage............... 125 V
                Battery Capacity............. 100 %
                Remaining Runtime............ 68 min.
                Load......................... 108 Watt(12 %)
                Line Interaction............. None
                Test Result.................. Passed at 2023/02/22 21:45:39
                Last Power Event............. None

freda@localhost.heavy1] ~ $

Attempt to change Service Status from Manual to On Boot

The following services(1) will be configured to start after booting:

pwrstatd

Apply all changes?

====================================================================
Writing the configuration failed:
Could not set 'pwrstatd' to be started on boot.
Would you like to continue editing?

Click Yes
Returned to RUNNING state - No Change
====================================================================

Show full output as root

ls -l /etc/systemd/system/pwrstatd.service
systemctl cat pwrstatd.service
systemctl enable pwrstatd.service
localhost:~ # ls -l /etc/systemd/system/pwrstatd.service
-rw-r--r-- 1 root root 281 Oct 30 11:18 /etc/systemd/system/pwrstatd.service
localhost:~ # systemctl cat pwrstatd.service
# /etc/systemd/system/pwrstatd.service
[Unit]
Description=The monitor UPS software.
After=network.target network-online.target nss-lookup.target

[Service]
Type=forking
ExecStart=/etc/init.d/pwrstatd start
ExecStop=/etc/init.d/pwrstatd stop
ExecReload=/etc/init.d/pwrstatd restart

[Install]
WantedBy=multi-user.target

localhost:~ # systemctl enable pwrstatd.service
Synchronizing state of pwrstatd.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable pwrstatd
error: malformated LSB header in pwrstatd: missing LSB end marker, aborting.
localhost:~ # 

Move /etc/init.d/pwrstatd somewhere else (/usr/local/bin or whatever) and adjust /etc/systemd/system/pwrstatd.service accordingly. You will need to run systemctl daemon-reload after this before enabling it.

Followed your instructions. Created susepaste entry as it was lengthy openSUSE Paste

I can start the daemon manually via a root cli or the Yast Services Manager but the Services Manager still refuses to create the boot setup.

I do not see either systemctl daemon-reload or systemctl enable pwrstatd.service invocation here so I am not sure what you did and what is your question. I cannot comment on something that I do not see.

I just re-ran the daemon-reload and the enable service.

localhost:~ # systemctl daemon-reload 
localhost:~ # systemctl enable pwrstatd.service
Synchronizing state of pwrstatd.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable pwrstatd
error: malformated LSB header in pwrstatd: missing LSB end marker, aborting.
localhost:~ # 

The daemon-reload appears to give no output (I could not find a “verbose” parameter) and the enable service is giving the same result as we saw before. Is it possible that the vendor module pwrstatd is faulty?

There is still /etc/init.d/pwrstatd

Is this a new installation? If so, it doesn’t look like it’s from the openSUSE repo. I use Tumbleweed, but it’s still a systemctl system and the install rpm doesn’t set anything up for init.d

I think I have found a resolution. I “created” an LSB block from documentation I found at

(https://www.suse.com/support/kb/doc/?id=000016866)

comprised of

### BEGIN INIT INFO
# Provides:       pwrstatd
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:  2 3 5
# Default-Stop:
# Description:    pwrstatd test LSB Header
### END INIT INFO

and placed it in the init.d entry pwrstatd. I then did the daemon-reload and enable.

localhost:~ # systemctl daemon-reload
localhost:~ # systemctl enable pwrstatd.service
Synchronizing state of pwrstatd.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable pwrstatd
ln -sf ../pwrstatd /etc/init.d/rc2.d/S50pwrstatd
ln -sf ../pwrstatd /etc/init.d/rc3.d/S50pwrstatd
ln -sf ../pwrstatd /etc/init.d/rc5.d/S50pwrstatd
Created symlink /etc/systemd/system/multi-user.target.wants/pwrstatd.service → /etc/systemd/system/pwrstatd.service.
localhost:~ #

I will test the automatic start at boot this weekend but System Services changed with the enable and now looks correct. I will contact the vendor with this information and we will see where that goes.

* pwrstatd.service - The monitor UPS software.
     Loaded: loaded (/etc/systemd/system/pwrstatd.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2023-03-01 12:06:03 MST; 27s ago
    Process: 11246 ExecStart=/usr/local/bin/pwrstatd start (code=exited, status=0/SUCCESS)
   Main PID: 11253 (pwrstatd)
      Tasks: 1 (limit: 4915)
     CGroup: /system.slice/pwrstatd.service
             `- 11253 /usr/sbin/pwrstatd

Mar 01 12:06:02 localhost.heavy1 systemd[1]: Starting The monitor UPS software....
Mar 01 12:06:03 localhost.heavy1 pwrstatd[11246]: Starting pwrstatd 1.4.1..done
Mar 01 12:06:03 localhost.heavy1 systemd[1]: Started The monitor UPS software..