Class: VpsCli::Setup
- Inherits:
-
Object
- Object
- VpsCli::Setup
- Defined in:
- lib/vps_cli/setup.rb
Overview
Various setup to include ufw firewalls, adding repos, adding fonts etc
Class Method Summary collapse
-
.add_asciinema_repo ⇒ Object
deprecated
Deprecated.
Now part of the standard packaging of Ubuntu 18.04+
- .add_dejavu_sans_mono_font ⇒ Object
-
.add_docker_repo ⇒ Object
deprecated
Deprecated.
Now part of the standard packaging of Ubuntu 18.04+
-
.add_mosh_repo ⇒ Object
deprecated
Deprecated.
Now part of the standard packaging of Ubuntu 18.04+
-
.add_neovim_repo ⇒ Object
deprecated
Deprecated.
Now part of the standard packaging of Ubuntu 18.04+
-
.add_repos ⇒ Object
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.
-
.add_yarn_repo ⇒ Object
deprecated
Deprecated.
Now part of the standard packaging of Ubuntu 18.04+
-
.full ⇒ Object
Runs the full setup process.
-
.privileged_user? ⇒ Boolean
checks if the user has sudo privileges via uid.
-
.root? ⇒ Boolean
checks if a user is root.
-
.ufw_setup ⇒ Object
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.
Class Method Details
.add_asciinema_repo ⇒ Object
Now part of the standard packaging of Ubuntu 18.04+
99 100 101 102 |
# 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 ⇒ Object
46 47 48 49 |
# 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 ⇒ Object
Now part of the standard packaging of Ubuntu 18.04+
66 67 68 69 70 71 72 73 74 75 |
# 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 ⇒ Object
Now part of the standard packaging of Ubuntu 18.04+
93 94 95 96 |
# 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 ⇒ Object
Now part of the standard packaging of Ubuntu 18.04+
87 88 89 90 |
# 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 ⇒ Object
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
56 57 58 59 60 61 62 63 |
# 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 ⇒ Object
Now part of the standard packaging of Ubuntu 18.04+
78 79 80 81 82 83 |
# 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 ⇒ Object
Runs the full setup process
21 22 23 24 25 26 27 |
# 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? ⇒ Boolean
checks if the user has sudo privileges via uid
7 8 9 |
# File 'lib/vps_cli/setup.rb', line 7 def self.privileged_user? Process.uid.zero? end |
.root? ⇒ Boolean
checks if a user is root
12 13 14 |
# File 'lib/vps_cli/setup.rb', line 12 def self.root? privileged_user? && Dir.home == '/root' end |
.ufw_setup ⇒ Object
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
33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 |