Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit files installed by packages are placed in
/usr/lib/systemd/system/
, but system administrators may also install unit files in/etc/systemd/system/
. An administrator might even do something crazy like nuke the default service file and install a custom one to/etc/systemd/system/
. As a result, this sort of test may be better:>&
sends both stdout and stderr to the specified file handle. See here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ichimonji10 even though I use the check you proposed I will have to check for those unit files to know if docker is installed or not. If the sysadmin changes places so the message showing that the services was restarted will not be printed.
Also other stuff I left according to what I found in other places in this codebase. But I can definitely update as per your suggestions, let's see what others tell about them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elyezer, I totally forgot about checking for docker.service in particular, so my example code is incomplete. Whoops! Still, I think there's a case to be made for using utilities to check for the presence of unit files or service files instead of directly querying the filesystem for the presence of files. I'd love to hear what others have to say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example deals with the case where the
systemctl
executable anddocker.service
unit file may or may not exist in standard locations on the system:I am not terribly knowledgeable about
service
and where service files may exist on a system.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ichimonji10 I tried your suggestion and get the following. Also I have to remove the docker.service option from
list-unit-files
. I will need to deal with the output of systemd not being available and that will make the code bigger. I will stick with 'Simple is better than complex.' here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elyezer OK. That sounds good.