Module: Capstrap::Hostname

Defined in:
lib/capistrano/ext/capstrap/hostname.rb

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/capistrano/ext/capstrap/hostname.rb', line 4

def self.load_into(configuration)
  configuration.load do

    namespace :hostname do

      desc "Sets the hostname."
      task :set_hostname do
        unless hostname_correct?(host_name)
          cmd = [
            %{echo "#{host_name}" > /etc/hostname},
            %{chown root:root /etc/hostname},
            %{chmod 0644 /etc/hostname},
            %{start hostname}
          ]
          run cmd.join(" && ")
        end
      end
    end
  end
end