Skip to content

Commit

Permalink
Add Debian docker capability for Docker's official packege
Browse files Browse the repository at this point in the history
/lib/systemd/system/docker.service in Docker's officaial package
does not include /etc/default/docker.
  • Loading branch information
otahi committed Sep 16, 2015
1 parent 0224941 commit b4f8689
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/vagrant-proxyconf/cap/debian/docker_proxy_conf.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require_relative '../util'

module VagrantPlugins
module ProxyConf
module Cap
module Debian
# Capability for docker proxy configuration
module DockerProxyConf
# @return [String, false] the path to docker or `false` if not found
def self.docker_proxy_conf(machine)
return false unless Util.which(machine, 'docker')

machine.communicate.tap do |comm|
src_file = '/lib/systemd/system/docker.service'
dst_file = '/etc/systemd/system/docker.service'
tmp_file = '/tmp/docker.service'
env_file = 'EnvironmentFile=-\/etc\/default\/docker'
comm.sudo("sed -e 's/\\[Service\\]/[Service]\\n#{env_file}/g' #{src_file} > #{tmp_file}")
unless comm.test("diff #{tmp_file} #{dst_file}")
# update config and restart docker when config changed
comm.sudo("mv -f #{tmp_file} #{dst_file}")
comm.sudo('systemctl daemon-reload')
end
comm.sudo("rm -f #{tmp_file}")
end
'/etc/default/docker'
end
end
end
end
end
end
5 changes: 5 additions & 0 deletions lib/vagrant-proxyconf/capability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class Plugin < Vagrant.plugin('2')
Cap::CoreOS::DockerProxyConf
end

guest_capability 'debian', 'docker_proxy_conf' do
require_relative 'cap/debian/docker_proxy_conf'
Cap::Debian::DockerProxyConf
end

guest_capability 'linux', 'env_proxy_conf' do
require_relative 'cap/linux/env_proxy_conf'
Cap::Linux::EnvProxyConf
Expand Down

0 comments on commit b4f8689

Please sign in to comment.