forked from tmatilai/vagrant-proxyconf
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Debian docker capability for Docker's official packege
/lib/systemd/system/docker.service in Docker's officaial package does not include /etc/default/docker.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters