Class: Bard::Provision::Swapfile

Inherits:
Bard::Provision show all
Defined in:
lib/bard/provision/swapfile.rb

Overview

setup swapfile

Instance Attribute Summary

Attributes inherited from Bard::Provision

#config, #ssh_url

Instance Method Summary collapse

Methods inherited from Bard::Provision

call

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bard/provision/swapfile.rb', line 4

def call
  print "Swapfile:"

  provision_server.run! "    if [ ! -f /swapfile ]; then\n      sudo fallocate -l $(grep MemTotal /proc/meminfo | awk '{print $2}')K /swapfile\n    fi\n    sudo chmod 600 /swapfile\n    sudo swapon --show | grep -q '/swapfile' || sudo mkswap /swapfile\n    sudo swapon --show | grep -q '/swapfile' || sudo swapon /swapfile\n    grep -q '/swapfile none swap sw 0 0' /etc/fstab || echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab\n  SH\n\n  puts \" \u2713\"\nend\n"