class VpsCli::Setup

Various setup to include ufw firewalls, adding repos, adding fonts etc

Public Class Methods

add_asciinema_repo() click to toggle source

@deprecated Now part of the standard packaging of Ubuntu 18.04+

# File lib/vps_cli/setup.rb, line 99
def self.add_asciinema_repo
  # asciinema repo for recording the terminal
  Rake.sh('sudo apt-add-repository -y ppa:zanchey/asciinema')
end
add_dejavu_sans_mono_font() click to toggle source
# File lib/vps_cli/setup.rb, line 46
def self.add_dejavu_sans_mono_font
  Rake.sh('mkdir -p ~/.local/share/fonts')
  Rake.sh(%(cd ~/.local/share/fonts && curl -fLo "DejaVu Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20Nerd%20Font%20Complete%20Mono.ttf))
end
add_docker_repo() click to toggle source

@deprecated Now part of the standard packaging of Ubuntu 18.04+

# File lib/vps_cli/setup.rb, line 66
def self.add_docker_repo
  # Instructions straight from https://docs.docker.com/install/linux/docker-ce/ubuntu/#set-up-the-repository
  # Docker repo
  Rake.sh('curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -')
  Rake.sh('sudo apt-key fingerprint 0EBFCD88')
  Rake.sh(%{yes "\n" | sudo add-apt-repository -y \
      "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
         $(lsb_release -cs) \
         stable"})
end
add_mosh_repo() click to toggle source

@deprecated Now part of the standard packaging of Ubuntu 18.04+

# File lib/vps_cli/setup.rb, line 93
def self.add_mosh_repo
  # mosh repo
  Rake.sh(%(yes "\n" | sudo add-apt-repository ppa:keithw/mosh))
end
add_neovim_repo() click to toggle source

@deprecated Now part of the standard packaging of Ubuntu 18.04+

# File lib/vps_cli/setup.rb, line 87
def self.add_neovim_repo
  # add neovim
  Rake.sh('sudo add-apt-repository ppa:neovim-ppa/stable')
end
add_repos() click to toggle source

Adds repos to the package manager to be tracked Adds the following repos: docker, yarn This method used to add neovim, asciinema, and mosh as well But they are all part of the base ubuntu 18.10 release

# File lib/vps_cli/setup.rb, line 56
def self.add_repos
  ## Now part of cosmic release for Ubuntu 18.10
  # add_yarn_repo
  # add_docker_repo
  # add_neovim_repo
  # add_mosh_repo
  # add_asciinema_repo
end
add_yarn_repo() click to toggle source

@deprecated Now part of the standard packaging of Ubuntu 18.04+

# File lib/vps_cli/setup.rb, line 78
def self.add_yarn_repo
  # yarn repo
  Rake.sh(%( curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -))
  Rake.sh(%(echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list))
  Rake.sh('sudo apt update')
end
full() click to toggle source

Runs the full setup process @see ufw_setup @see add_dejavu_sans_mono_font @see add_repos this method is deprecated due to all packages being added

to latest ubuntu 18.04+
# File lib/vps_cli/setup.rb, line 21
def self.full
  # this is here for compatibility purposes, no longer runs anything
  add_repos
  add_dejavu_sans_mono_font

  ufw_setup
end
privileged_user?() click to toggle source

checks if the user has sudo privileges via uid

# File lib/vps_cli/setup.rb, line 7
def self.privileged_user?
  Process.uid.zero?
end
root?() click to toggle source

checks if a user is root

# File lib/vps_cli/setup.rb, line 12
def self.root?
  privileged_user? && Dir.home == '/root'
end
ufw_setup() click to toggle source

Sets up ufw for you to be able to have certain firewalls in place Must be run after installing ufw via sudo apt install ufw

# File lib/vps_cli/setup.rb, line 33
def self.ufw_setup
  Rake.sh('sudo ufw default deny incoming')
  Rake.sh('sudo ufw default allow outgoing')
  # allows ssh & mosh connections
  Rake.sh('sudo ufw allow 60000:61000/tcp')

  # Typical ssh port
  Rake.sh('sudo ufw allow 22')

  Rake.sh('yes | sudo ufw enable')
  Rake.sh('yes | sudo systemctl restart sshd')
end