On 05/12/2011 03:12 PM, Michal Schmidt wrote:
On Thu, 12 May 2011 15:28:54 +0200 Michal Hlavinka wrote:
> > 1) does systemd support alternative to "service sthd configtest" or
> > other special actions?
No.
You can run ExecStartPre= before starting a service for syntax checking
before starting the service like we do for ..
*Freeradius*
ExecStartPre=/usr/sbin/radiusd -C
*Bind*
ExecStartPre=/usr/sbin/named-checkconf /etc/named.conf
*Cups*
ExecStartPre=/usr/sbin/cupsd -t
*Apache* ( happens on reload )
ExecReload=/usr/sbin/httpd.event $OPTIONS -t
etc...
Then there is a question given that this is an hardware related service
that that you would want to hardware activate the service with some udev
+ systemd magic like this..
*Warning* take this example with a grain of salt since I'm as green as
it gets when it comes to udev stuff hopefully udev experts wont throw up
and kill me for this.. *Warning*
Something like this which would reside in In something like
$number-nut-usbups-systemd.rules
Like...
SUBSYSTEM=="ups", TAG+="systemd",
ENV{SYSTEMD_WANTS}="ups.target"
Or
SUBSYSTEM=="ups", TAG+="systemd",
ENV{SYSTEMD_ALIAS}="/sys/path/to/ups/devices/%k"
Or
Using an example from /lib/udev/rules.d/62-nut-usbups.rules
Mapping 1 to 1 entries from the supplied udev file
# T500 - bcmxcp_usb
ATTR{idVendor}=="03f0", ATTR{idProduct}=="1f01",
MODE="664",
GROUP="dialout"
Would look something like this assuming idProduct==ID_MODEL_ID
ENV{ID_VENDOR_ID}=="03f0",ENV{ID_MODEL_ID}=="1f01"
TAG+="systemd",
ENV{SYSTEMD_WANTS}="ups.target"
*ups.target* would look something like this..
[Unit]
Description=Uninterruptible Power Source ( UPS )
StopWhenUnneeded=yes
*upsd.service* something like this
[Unit]
Description=UPS Monitor Master.
Requires=upsd-driver.service upsd-monitor.service
After=syslog.target upsd-driver.service
Before= upsd-monitor.service
[Service]
Type=forking
PIDFile=/var/run/nut/upsd.pid
EnvironmentFile=-/etc/sysconfig/ups
ExecStart=/usr/sbin/upsd $UPSD_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
TimeoutSec=5
[Install]
WantedBy=ups.target
You would plug in the ups and voila it *should* get activated.
JBG