[systemd-devel] problem with service that uses bash loop

Michał Piotrowski mkkp4x4 at gmail.com
Tue Mar 29 12:15:37 PDT 2011


W dniu 29 marca 2011 21:07 użytkownik Lennart Poettering
<lennart at poettering.net> napisał:
> On Tue, 29.03.11 21:06, Michał Piotrowski (mkkp4x4 at gmail.com) wrote:
>
>> >> [Install]
>> >> WantedBy=multi-user.target
>> >>
>> >> It works well until I add
>> >> ExecStop=/bin/bash -c "for module in $HWMON_MODULES $BUS_MODULES; do
>> >> /sbin/modprobe -r $module >/dev/null 2>&1; done"
>> >>
>> >> Is there some magical way in which I can make a simple loop in
>> >> ExecStop?
>> >
>> > Hmm, are you suggesting that this works in ExecStart but not in
>> > ExecStop? That would be a bug.
>>
>> I tried
>> ExecStop=-/sbin/modprobe -qabr $BUS_MODULES $HWMON_MODULES
>> too and also does not work.
>
> What precisely fails? Is the command line not properly constructed? Do
> you have any further hints?

Hmm... strange

loaded modules

Module                  Size  Used by
ecryptfs               86341  1
i2c_i801                9213  0
serio_raw               4426  0
iTCO_wdt               11480  0
iTCO_vendor_support     2634  1 iTCO_wdt
r8169                  35525  0
mii                     4318  1 r8169
ipv6                  282007  77
sata_sil                8104  0
i915                  346255  0
drm_kms_helper         27243  1 i915
drm                   187712  2 i915,drm_kms_helper
i2c_algo_bit            4950  1 i915
i2c_core               25468  5 i2c_i801,i915,drm_kms_helper,drm,i2c_algo_bit
video                  12432  1 i915


I start this script

[Unit]
Description=lm_sensors for monitoring motherboard sensor values
After=syslog.target

[Service]
EnvironmentFile=/etc/sysconfig/lm_sensors
Type=oneshot
ExecStart=-/sbin/modprobe -qab $BUS_MODULES $HWMON_MODULES
ExecStart=/usr/bin/sensors -s
#ExecStop=-/sbin/modprobe -qabr $BUS_MODULES $HWMON_MODULES

[Install]
WantedBy=multi-user.target

Now I've got

Module                  Size  Used by
smsc47m192             12267  0
hwmon_vid               2171  1 smsc47m192
coretemp                5771  0
ecryptfs               86341  1
i2c_i801                9213  0
serio_raw               4426  0
iTCO_wdt               11480  0
iTCO_vendor_support     2634  1 iTCO_wdt
r8169                  35525  0
mii                     4318  1 r8169
ipv6                  282007  77
sata_sil                8104  0
i915                  346255  0
drm_kms_helper         27243  1 i915
drm                   187712  2 i915,drm_kms_helper
i2c_algo_bit            4950  1 i915
i2c_core               25468  6
smsc47m192,i2c_i801,i915,drm_kms_helper,drm,i2c_algo_bit
video                  12432  1 i915

as you can see smsc47m192 is loaded

I uncomment
ExecStop=-/sbin/modprobe -qabr $BUS_MODULES $HWMON_MODULES

and run
systemctl daemon-reload
and
systemctl stop lm_sensors.service

I still have smsc47m192 loaded but when I do

systemctl start lm_sensors.service

module is unloaded

Module                  Size  Used by
ecryptfs               86341  1
i2c_i801                9213  0
serio_raw               4426  0
iTCO_wdt               11480  0
iTCO_vendor_support     2634  1 iTCO_wdt
r8169                  35525  0
mii                     4318  1 r8169
ipv6                  282007  77
sata_sil                8104  0
i915                  346255  0
drm_kms_helper         27243  1 i915
drm                   187712  2 i915,drm_kms_helper
i2c_algo_bit            4950  1 i915
i2c_core               25468  5 i2c_i801,i915,drm_kms_helper,drm,i2c_algo_bit
video                  12432  1 i915



>
> Lennart
>
> --
> Lennart Poettering - Red Hat, Inc.
>



-- 
Best regards,
Michal

http://eventhorizon.pl/


More information about the systemd-devel mailing list