File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -169,14 +169,25 @@ class SystemdService(SysvService):
169
169
170
170
def _has_systemd_suffix (self ):
171
171
"""
172
- Check if service name has a known systemd unit suffix
172
+ Check if the service name has a known systemd unit suffix
173
173
"""
174
174
unit_suffix = self .name .split ("." )[- 1 ]
175
175
return unit_suffix in self .suffix_list
176
176
177
177
@property
178
178
def exists (self ):
179
- cmd = self .run_test ('systemctl list-unit-files | grep -q "^%s"' , self .name )
179
+ # systemctl offers “list-units” and “list-unit-files” to list unit
180
+ # files. Unfortunately, neither command provides a complete list of
181
+ # unit files. Therefore, both commands are queried one after the
182
+ # other.
183
+ cmd = self .run_test (
184
+ r'systemctl list-units --all | grep -q "^[[:space:]]*%s"' , self .name
185
+ )
186
+ if cmd .rc == 0 :
187
+ return True
188
+ cmd = self .run_test (
189
+ r'systemctl list-unit-files | grep -q "^[[:space:]]*%s"' , self .name
190
+ )
180
191
return cmd .rc == 0
181
192
182
193
@property
You can’t perform that action at this time.
0 commit comments