Method: Bosh::Agent::Bootstrap#setup_tmp

Defined in:
lib/bosh_agent/bootstrap.rb

#setup_tmpObject



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/bosh_agent/bootstrap.rb', line 240

def setup_tmp
  # use a custom TMPDIR for agent itself
  agent_tmp_dir = File.join(base_dir, 'data', 'tmp')
  FileUtils.mkdir_p(agent_tmp_dir)
  ENV["TMPDIR"] = agent_tmp_dir

  # first time: for /tmp on the root fs
  tmp_permissions

  unless Pathname.new('/tmp').mountpoint?
    tmp_size = 128
    root_tmp = File.join(base_dir, 'data', 'root_tmp')

    # If it's not mounted on /tmp - we don't care - blow it away
    %x[/usr/bin/truncate -s #{tmp_size}M #{root_tmp}]
    %x[chmod 0700 #{root_tmp}]
    %x[mke2fs -t ext4 -m 1 -F #{root_tmp}]

    %x[mount -t ext4 -o loop #{root_tmp} /tmp]

    # 2nd time for the new /tmp mount
    tmp_permissions
  end
end