Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inhibit docker restarting when no configuration change #92

Merged
merged 2 commits into from
Nov 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/vagrant-proxyconf/action/configure_docker_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ def write_docker_config
comm.sudo("touch #{path}")
comm.sudo("sed -e '#{sed_script}' #{path} > #{path}.new")
comm.sudo("cat #{tmp} >> #{path}.new")
comm.sudo("chmod 0644 #{path}.new")
comm.sudo("chown root:root #{path}.new")
comm.sudo("mv #{path}.new #{path}")
comm.sudo("rm #{tmp}")
comm.sudo(service_restart_command)
update_config(path)
comm.sudo("rm -f #{tmp} #{path}.new")
end
end

def update_config(path)
return if comm.test("diff #{path}.new #{path}")

# update config and restart docker when config changed
comm.sudo("chmod 0644 #{path}.new")
comm.sudo("chown root:root #{path}.new")
comm.sudo("mv #{path}.new #{path}")
comm.sudo(service_restart_command)
end

def detect_export
@machine.communicate.tap do |comm|
comm.test('which systemctl') ? @export = '' : @export = 'export '
Expand Down
10 changes: 7 additions & 3 deletions lib/vagrant-proxyconf/cap/coreos/docker_proxy_conf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ def self.docker_proxy_conf(machine)

machine.communicate.tap do |comm|
src_file='/usr/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}")

comm.sudo('mv /tmp/docker.service /etc/systemd/system/')
comm.sudo('systemctl daemon-reload')
unless comm.test("diff #{tmp_file} #{dst_file}")
# update config and restart docker when config changed
comm.sudo("mv #{tmp_file} #{dst_file}")
comm.sudo('systemctl daemon-reload')
end
comm.sudo("rm -f #{tmp}")
end
'/etc/default/docker'
end
Expand Down