Skip to content

Commit

Permalink
Fix docker::run when used on systemd
Browse files Browse the repository at this point in the history
**These patches do not block upgrading to the latest garether-docker;
they can both be dropped.**

Both of these changes are only necessary because we are so far behind
upstream, which already has very good support for systemd.

The change to the exit code was proposed upstream anyway as it is an
overall good patch (init scripts are supposed to exit 0 when asked to
start and the service is already running):
garethr#626
  • Loading branch information
chriskuehl committed Jan 27, 2017
1 parent 93f4f51 commit 743496c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion manifests/run.pp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,15 @@

service { "docker-${sanitised_title}":
ensure => $running,
enable => true,
enable => $::lsbdistcodename ? {
# upstart
lucid => true,
trusty => true,
# systemd can't handle enabling/disabling of /etc/init.d scripts.
# We could remove this if we upgraded to the latest garethr-docker (it
# supports systemd).
default => undef,
},
hasstatus => $hasstatus,
hasrestart => $hasrestart,
require => File[$initscript],
Expand Down
4 changes: 2 additions & 2 deletions templates/etc/init.d/docker-run.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ start() {

if [ "true" = "$($docker inspect --format='{{.State.Running}}' <%= @sanitised_title %>)" ]; then
failure
printf "Container <%= @sanitised_title %> is still running.\n"
exit 7
printf "Container <%= @sanitised_title %> is already running.\n"
exit 0
fi

printf "Starting $prog:\t"
Expand Down

0 comments on commit 743496c

Please sign in to comment.