Module: VagrantPlugins::ProxyConf::Cap::Debian::DockerProxyConf
- Defined in:
- lib/vagrant-proxyconf/cap/debian/docker_proxy_conf.rb
Overview
Capability for docker proxy configuration
Constant Summary collapse
- CONFIG_DIR =
'/etc/default/'
Class Method Summary collapse
-
.docker_proxy_conf(machine) ⇒ String, false
The path to docker or ‘false` if not found.
Class Method Details
.docker_proxy_conf(machine) ⇒ String, false
Returns the path to docker or ‘false` if not found.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-proxyconf/cap/debian/docker_proxy_conf.rb', line 12 def self.docker_proxy_conf(machine) docker_command = find_docker_command(machine) return false if docker_command.nil? config_path = CONFIG_DIR + docker_command return config_path unless Util.which(machine, 'systemctl') machine.communicate.tap do |comm| src_file = "/lib/systemd/system/#{docker_command}.service" dst_file = "/etc/systemd/system/#{docker_command}.service" tmp_file = "/tmp/#{docker_command}.service" env_file = "EnvironmentFile=-\\/etc\\/default\\/#{docker_command}" if comm.test("grep -q -e '#{env_file}' #{src_file}") comm.sudo("cp -p #{src_file} #{tmp_file}") else comm.sudo("sed -e 's/\\[Service\\]/[Service]\\n#{env_file}/g' #{src_file} > #{tmp_file}") end 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 config_path end |