Systemd unit file implementation questions (ypbind)

"Jóhann B. Guðmundsson" johannbg at gmail.com
Thu Apr 14 14:46:01 UTC 2011


On 04/14/2011 12:51 PM, Michal Hlavinka wrote:
>
>> Can you elaborate on this?
> a) ups driver - runs when you have ups attached to that host
> b) upsd - runs when you have ups attached to that host
> c) upsmon (master/slave mode) - usualy runs on machine where you have ups, but it can run
> on machine without ups or work with different ups than the attached one
>

Looking at the old sysv it only does 2 things...

if the $SERVER = yes in /etc/sysconfig/ups then start upsd driver upsd 
and upsd monitor.

If the $SERVER != yes in /etc/sysconfig/ups then only start the monitor 
service

start() {
         if [ "$SERVER" = "yes" ]; then
                 echo -n $"Starting UPS driver controller: "
                 daemon /sbin/upsdrvctl start > /dev/null 2>&1 && 
success || failure
                 RETVAL=$?
                 echo

                 prog="upsd"
                 echo -n $"Starting $prog: "
                 daemon /usr/sbin/upsd $UPSD_OPTIONS > /dev/null 2>&1 && 
success || failure
                 if [ "$RETVAL" = 0 ]; then
                         RETVAL=$?
                 fi
                 echo

                 echo -n $"Starting UPS monitor (master): "
                 daemon --pidfile /var/run/nut/upsmon.pid 
/usr/sbin/upsmon > /dev/null 2>&1 && success || failure
                 if [ "$RETVAL" = 0 ]; then
                         RETVAL=$?
                 fi
                 echo
         else
                 echo -n $"Starting UPS monitor (slave): "
                 daemon --pidfile /var/run/nut/upsmon.pid 
/usr/sbin/upsmon > /dev/null 2>&1 && success || failure
                 echo
         fi

         [ "$RETVAL" = 0 ] && touch /var/lock/subsys/ups
}


The only difference between usps-monitor in master mode and slave mode 
is the "echo (master)"/"echo (slave)"

Now I've splitted this into three systemd services upsd.service 
upsd-driver.service and upsd-monitor

upsd.service which if run will start uspd upsd-driver and the 
upsd-monitor this is the same behavior as if $SERVER = yes

upsd-driver.service is stand alone and can be started stopped etc all by 
it self

upsd-monitor.service is stand alone and can be started stopped etc all 
by it self.

Starting this service on it's own is the exact same behaviour if $SERVER 
!= yes

This is as close and as correct transfer to systemd as it gets.

The $SERVER variable in /etc/sysconfig/ups is obsoleted

If end users wants the uspd server ( which by the way defaulted to yes 
so this even is not a breakage in default behaviour ) they only need to run

service upsd start or systemctl start upsd.service just ast they did before.

If they just want to use the monitor they just start the UPS Monitor 
service

And now they can even start the UPS driver controller only which they 
could not before.

JBG


More information about the devel mailing list