# Postfix is not installed in img-basic anymore
#
# if disable_ipv6 == 1
#   postfix_host = '127.0.0.1'
# else
#   postfix_host = 'localhost'
# end
#
# file_replace_line "ipv4-patch-postfix-conf" do
#   path      '/etc/postfix/main.cf'
#   replace   "inet_interfaces = localhost"
#   with      "inet_interfaces = #{postfix_host}"
#   not_if   "grep 'inet_interfaces = #{postfix_host}' /etc/postfix/main.cf"
# end

execute 'clean_hosts' do
  command "/bin/sed -e '/^::.*$/d' -i /etc/hosts"
  only_if "cat /etc/hosts | grep '::.'"
end

template '/etc/sysctl.conf' do
  source 'network/sysctl.conf.erb'
  owner 'root'
  group 'root'
  mode 00664
  notifies :run, 'execute[update-sysctl]', :delayed
end

execute 'update-sysctl' do
  command 'sysctl -p'
  action :nothing
end

# TODO
# # Original method didn't work
# cookbook_file "/etc/setIW10.sh" do
#   source "setIW10"
#   owner "root"
#   group "root"
#   mode 00755
# end
#
# bash "setIW10" do
#   code <<-EOH
#     /etc/setIW10.sh
#     EOH
# end
#
