guess_os 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.standard.yml +3 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +12 -0
  5. data/Gemfile.lock +48 -0
  6. data/LICENSE +674 -0
  7. data/README.md +30 -0
  8. data/Rakefile +19 -0
  9. data/examples/demo-1-input.rb +25 -0
  10. data/examples/demo-2-input.rb +40 -0
  11. data/examples/demo-3-staticvalues.rb +9 -0
  12. data/examples/demo-4-staticvalues.rb +28 -0
  13. data/guess_os.gemspec +38 -0
  14. data/lib/guess_os/conn.rb +76 -0
  15. data/lib/guess_os/host.rb +27 -0
  16. data/lib/guess_os/os.rb +16 -0
  17. data/lib/guess_os/type.rb +92 -0
  18. data/lib/guess_os/version.rb +6 -0
  19. data/lib/guess_os.rb +7 -0
  20. data/sig/guess_os.rbs +4 -0
  21. data/vagrant/.gitignore +5 -0
  22. data/vagrant/debian/.gitignore +2 -0
  23. data/vagrant/debian/Vagrantfile +23 -0
  24. data/vagrant/manjaro/.gitignore +3 -0
  25. data/vagrant/manjaro/Vagrantfile +22 -0
  26. data/vagrant/manjaro/Vagrantfile.1mv +26 -0
  27. data/vagrant/minix/.gitignore +3 -0
  28. data/vagrant/minix/README.md +6 -0
  29. data/vagrant/minix/Vagrantfile +19 -0
  30. data/vagrant/opensuse/.gitignore +4 -0
  31. data/vagrant/opensuse/Vagrantfile +25 -0
  32. data/vagrant/opensuse.kde/.gitignore +1 -0
  33. data/vagrant/opensuse.kde/Vagrantfile +20 -0
  34. data/vagrant/ubuntu/.gitignore +2 -0
  35. data/vagrant/ubuntu/02-install-software.rb +27 -0
  36. data/vagrant/ubuntu/Vagrantfile +27 -0
  37. data/vagrant/ubuntu/install-software.rb +27 -0
  38. data/vagrant/windows10/.gitignore +1 -0
  39. data/vagrant/windows10/Vagrantfile +17 -0
  40. data/vagrant/windows10/Vagrantfile.edge +19 -0
  41. data/vagrant/windows7/.gitignore +2 -0
  42. data/vagrant/windows7/Vagrantfile +21 -0
  43. data/vagrant/winserver/.gitignore +3 -0
  44. data/vagrant/winserver/Vagrantfile +19 -0
  45. metadata +88 -0
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+
2
+ # GuessOS
3
+
4
+ Try to guess the operating system installed on the host (local or remote)
5
+
6
+ # Documentation
7
+
8
+ 1. Install Ruby on your system.
9
+ 1. `gem install --user-install guess_os`, to install gem.
10
+
11
+ # Usage
12
+
13
+ ```ruby
14
+ require 'guess_os'
15
+
16
+ host = GuessOS::Host.new(
17
+ ip: 'localhost',
18
+ port: 2241,
19
+ username: 'vagrant',
20
+ password: 'vagrant'
21
+ )
22
+
23
+ puts host.os.name
24
+ ```
25
+
26
+ > More [examples](examples)
27
+
28
+ # Contact
29
+
30
+ * **Email**: `teuton.software@protonmail.com`
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "standard/rake"
13
+
14
+ task default: %i[test standard]
15
+ #require "bundler/setup"
16
+ #require "bump/tasks"
17
+
18
+ #Bundler::GemHelper.install_tasks
19
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/guess_os/host'
4
+
5
+ puts "[GuessOS] #{$0}"
6
+
7
+ print ' ip? '; ip = gets.chomp
8
+ print ' port? '; port = gets.chomp
9
+ print 'username? '; username = gets.chomp
10
+ print 'password? '; password = gets.chomp
11
+
12
+ ip = 'localhost' if ip.empty?
13
+ port = nil if port.empty?
14
+ username = nil if username.empty?
15
+ password = nil if password.empty?
16
+
17
+ host = GuessOS::Host.new(
18
+ ip: ip,
19
+ port: port,
20
+ username: username,
21
+ password: password
22
+ )
23
+
24
+ puts '=' * 50 + "\n"
25
+ puts host.os.to_s
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/guess_os/host'
4
+
5
+ puts "[GuessOS] #{$0}"
6
+
7
+ print ' ip? '; ip = gets.chomp
8
+ print ' port? '; port = gets.chomp
9
+ print 'username? '; username = gets.chomp
10
+ print 'password? '; password = gets.chomp
11
+
12
+ port = nil if port.empty?
13
+ username = nil if username.empty?
14
+ password = nil if password.empty?
15
+
16
+ host = GuessOS::Host.new(
17
+ ip: ip,
18
+ port: port,
19
+ username: username,
20
+ password: password
21
+ )
22
+
23
+ puts "\n"
24
+ puts "==> Show host info"
25
+ puts " ip = #{host.ip}"
26
+ puts " port = #{host.port}"
27
+ puts " username = #{host.username}"
28
+ puts " password = #{host.password}"
29
+
30
+ conn = GuessOS::Conn.new(host)
31
+
32
+ cmd = 'lsb_release -d'
33
+ puts "\n==> Execute command: #{cmd}"
34
+ puts " #{conn.exec(cmd)}"
35
+
36
+ puts "\n"
37
+ puts "==> Show Type info (#{host.ip}:#{host.port})"
38
+ puts " type = #{host.os.type}"
39
+ puts " name = #{host.os.name}"
40
+ puts " desc = #{host.os.desc}"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/guess_os/host'
4
+
5
+ puts "[GuessOS] #{$0}"
6
+ puts '-' * 50 + "\n"
7
+
8
+ host = GuessOS::Host.new(ip: 'localhost')
9
+ puts host.os.to_s
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/guess_os/host'
4
+ require_relative '../lib/guess_os/conn'
5
+
6
+ puts "[GuessOS] #{$0}"
7
+ puts '-' * 50
8
+
9
+ host = GuessOS::Host.new(ip: 'localhost')
10
+
11
+ puts "\n"
12
+ puts "==> Show host info"
13
+ puts " ip = #{host.ip}"
14
+ puts " port = #{host.port}"
15
+ puts " username = #{host.username}"
16
+ puts " password = #{host.password}"
17
+
18
+ conn = GuessOS::Conn.new(host)
19
+
20
+ cmd = 'lsb_release -d'
21
+ puts "\n==> Execute command: #{cmd}"
22
+ puts " #{conn.exec(cmd)}"
23
+
24
+ puts "\n"
25
+ puts "==> Show Type info (#{host.ip}:#{host.port})"
26
+ puts " type = #{host.os.type}"
27
+ puts " name = #{host.os.name}"
28
+ puts " desc = #{host.os.desc}"
data/guess_os.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/guess_os/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "guess_os"
7
+ spec.version = GuessOS::VERSION
8
+ spec.authors = ["David Vargas"]
9
+ spec.email = ["dvarrui@protonmail.com"]
10
+
11
+ spec.summary = "Guess local or remote OS."
12
+ spec.description = "Guess local or remote OS."
13
+ spec.homepage = "https://github.com/dvarrui/guess_os"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/dvarrui/guess_os"
20
+ spec.metadata["changelog_uri"] = "https://github.com/dvarrui/guess_os/CHANGELOG.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+
36
+ # For more information and examples about making a new gem, check out our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
@@ -0,0 +1,76 @@
1
+
2
+ require 'net/ssh'
3
+
4
+ module GuessOS
5
+ class Conn
6
+ attr_reader :host
7
+ attr_reader :ok
8
+ attr_reader :status
9
+ attr_reader :last_output
10
+
11
+ def initialize(host)
12
+ @host = host
13
+ @last_output = ''
14
+ @status = nil
15
+ @ok = nil
16
+ end
17
+
18
+ def exec(command)
19
+ @ok = :unkown
20
+ @status = :unkown
21
+
22
+ return local_exec(command) if host.local?
23
+ remote_exec(command)
24
+ end
25
+
26
+ def local_exec(command)
27
+ output = `#{command}`
28
+ if $?.exitstatus.zero?
29
+ @ok = true
30
+ @status = 'Ok'
31
+ else
32
+ @ok = false
33
+ @status = "Exit status: #{$?.exitstatus}"
34
+ end
35
+
36
+ @last_output = output
37
+ end
38
+
39
+ def remote_exec(command)
40
+ output = 'Error'
41
+ begin
42
+ session = Net::SSH.start(@host.ip,
43
+ @host.username,
44
+ port: @host.port,
45
+ password: @host.password,
46
+ keepalive: true,
47
+ timeout: 30,
48
+ non_interactive: true)
49
+ if session.class == Net::SSH::Connection::Session
50
+ output = session.exec!(command)
51
+ @status = :ok
52
+ @ok = true
53
+ end
54
+ rescue Errno::EHOSTUNREACH
55
+ @status = "[ERROR] Host #{@host.ip} unreachable!"
56
+ rescue Net::SSH::AuthenticationFailed
57
+ @status = '[ERROR] SSH::AuthenticationFailed!'
58
+ rescue Net::SSH::HostKeyMismatch
59
+ @status = 'SSH::HostKeyMismatch!'
60
+ puts("* The destination server's fingerprint is not matching " \
61
+ 'what is in your local known_hosts file.')
62
+ puts('* Remove the existing entry in your local known_hosts file')
63
+ puts("* Try this => ssh-keygen -f '/home/USERNAME/.ssh/known_hosts' " \
64
+ "-R #{@host.ip}")
65
+ rescue SocketError
66
+ @status = "[ERROR] SocketError with IP/port [#{@host.ip}:#{@host.port}]"
67
+ rescue Errno::ECONNREFUSED
68
+ @status = "[ERROR] ConnRefused: SSH on [#{@host.username}@#{@host.ip}:#{@host.port}]"
69
+ rescue StandardError => e
70
+ @status = "[#{e.class}] SSH on <#{@host.username}@#{@host.ip}:#{@host.port}>" \
71
+ " exec: #{command}"
72
+ end
73
+ @last_output = output
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,27 @@
1
+
2
+ require_relative 'type'
3
+
4
+ module GuessOS
5
+ class Host
6
+ attr_reader :ip, :port, :username, :password
7
+ attr_reader :os
8
+
9
+ def initialize(args = {})
10
+ @ip = args[:ip] || 'localhost'
11
+ @port = args[:port] || '22'
12
+ @username = args[:username] || 'root'
13
+ @password = args[:password] || 'vagrant'
14
+ @os = GuessOS::Type.guess(self)
15
+ end
16
+
17
+ def local?
18
+ return true if (ip == 'localhost') || (ip == '127.0.0.1')
19
+
20
+ false
21
+ end
22
+
23
+ def remote?
24
+ !local?
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+
2
+ module GuessOS
3
+ class OS
4
+ attr_reader :type, :name, :desc
5
+
6
+ def initialize(type, name, desc)
7
+ @type = type
8
+ @name = name
9
+ @desc = desc
10
+ end
11
+
12
+ def to_s
13
+ { type: @type, name: @name, desc: @desc }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,92 @@
1
+
2
+ require_relative 'conn'
3
+ require_relative 'os'
4
+
5
+ module GuessOS
6
+ module Type
7
+ def self.guess(host)
8
+ os = guess_gnulinux(host)
9
+ return os unless os.type == :unkown
10
+
11
+ os = guess_cygwin(host)
12
+ return os unless os.type == :unkown
13
+
14
+ os = guess_windows(host)
15
+ return os unless os.type == :unkown
16
+
17
+ os = guess_minix(host)
18
+ return os unless os.type == :unkown
19
+
20
+ os
21
+ end
22
+
23
+ def self.guess_gnulinux(host)
24
+ conn = GuessOS::Conn.new(host)
25
+ command = 'lsb_release -d'
26
+
27
+ conn.exec(command)
28
+ return OS.new(:unkown, :unkown, conn.status) unless conn.ok
29
+
30
+ output = conn.last_output
31
+ items = output.split
32
+ type = 'gnu/linux'
33
+ name = items[1]&.downcase
34
+ desc = output
35
+
36
+ list = %w(debian ubuntu opensuse manjaro)
37
+ unless list.include? name
38
+ return OS.new(:unkown, :unkown, 'Unkown OS')
39
+ end
40
+
41
+ OS.new(type, name, desc)
42
+ end
43
+
44
+ def self.guess_windows(host)
45
+ conn = GuessOS::Conn.new(host)
46
+ command = 'echo %windir%'
47
+ conn.exec(command)
48
+
49
+ identified = conn.ok && conn.last_output.include?('Windows')
50
+ return OS.new(:unkown, :unkown, conn.status) unless identified
51
+
52
+ output = conn.last_output
53
+ type = 'windows'
54
+ name = 'windows'
55
+ desc = output.gsub("\r", '')
56
+ desc.gsub!("\n", '')
57
+ OS.new(type, name, desc)
58
+ end
59
+
60
+ def self.guess_cygwin(host)
61
+ conn = GuessOS::Conn.new(host)
62
+ command = 'pwd'
63
+ conn.exec(command)
64
+
65
+ identified = conn.ok && conn.last_output.include?('/cygdrive')
66
+ return OS.new(:unkown, :unkown, conn.status) unless identified
67
+
68
+ output = conn.last_output
69
+ type = 'cygwin'
70
+ name = 'cygwin'
71
+ desc = output.gsub("\n", '')
72
+ OS.new(type, name, desc)
73
+ end
74
+
75
+ def self.guess_minix(host)
76
+ conn = GuessOS::Conn.new(host)
77
+ command = 'cat /etc/rc.d/minixrc |grep MINIX| head -n 1'
78
+
79
+ conn.exec(command)
80
+
81
+ identified = conn.ok && conn.last_output.include?('MINIX')
82
+ return OS.new(:unkown, :unkown, conn.status) unless identified
83
+
84
+ output = conn.last_output
85
+ items = output.split
86
+ type = 'minix'
87
+ name = 'minix'
88
+ desc = output.gsub("\n", '')
89
+ OS.new(type, name, desc)
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GuessOS
4
+ VERSION = "0.1.0"
5
+ NAME = 'guess_os'
6
+ end
data/lib/guess_os.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "guess_os/version"
4
+ require_relative 'guess_os/host'
5
+
6
+ module GuessOS
7
+ end
data/sig/guess_os.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module GuessOs
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
@@ -0,0 +1,5 @@
1
+ .vagrant
2
+ .ruby-version
3
+ *.gem
4
+ *.sh
5
+ teuton-*
@@ -0,0 +1,2 @@
1
+ .vagrant
2
+ *.log
@@ -0,0 +1,23 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.define "vagrant-debian" do |i|
6
+ # Configure BOX
7
+ i.vm.box = "generic/debian11"
8
+
9
+ # Configure VM
10
+ i.vm.hostname = "vagrant-debian"
11
+ #i.vm.network "public_network", bridge: [ "eth0" ]
12
+ #i.vm.network "public_network", bridge: [ "wlp6s0" ]
13
+ i.vm.network :forwarded_port, guest: 22, host: 2241
14
+ i.vm.synced_folder "./", "/vagrant"
15
+ i.vm.provision "shell", path: 'install-software.sh'
16
+
17
+ # Configure VIRTUALBOX
18
+ i.vm.provider "virtualbox" do |v|
19
+ v.name = 'vagrant-debian'
20
+ v.memory = 2048
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ .vagrant
2
+ *.log
3
+ private*
@@ -0,0 +1,22 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.define "vagrant-manjaro" do |i|
6
+ i.vm.box = "marashni/manjaro64"
7
+ i.vm.box_version = "0.0.1"
8
+ i.vm.hostname = "vagrant-manjaro"
9
+ # i.vm.network "public_network", bridge: [ "eth0" ]
10
+ # i.vm.network "public_network", bridge: [ "wlan0" ]
11
+ i.vm.network :forwarded_port, guest: 22, host: 2251
12
+ i.vm.synced_folder "./", "/vagrant"
13
+ i.vm.provision "shell", inline: <<-SHELL
14
+ lsb_release -d
15
+ SHELL
16
+ i.vm.provider "virtualbox" do |vm|
17
+ vm.name = 'vagrant-manjaro'
18
+ vm.memory = 2048
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,26 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.box = "marashni/manjaro64"
6
+ config.vm.box_version = "0.0.1"
7
+
8
+ config.vm.hostname = "vagrant-manjaro"
9
+ config.vm.synced_folder "./", "/vagrant"
10
+
11
+ config.vm.provider "virtualbox" do |vm|
12
+ vm.name = 'vagrant-manjaro'
13
+ vm.memory = 2048
14
+ end
15
+
16
+ ##
17
+ # config.vm.define "mv1" do |i|
18
+ # i.vm.box = "marashni/manjaro64"
19
+ # ...
20
+ # end
21
+ #
22
+ # config.vm.define "mv2" do |i|
23
+ # ...
24
+ # end
25
+ end
26
+
@@ -0,0 +1,3 @@
1
+ .vagrant
2
+ private*
3
+ *.log
@@ -0,0 +1,6 @@
1
+
2
+ # minix3
3
+
4
+ * [Instalar paquetes](https://veopinguinos.wordpress.com/2015/03/02/minix-3-ii-configuracion-y-algo-de-administracion/)
5
+ * [Configurar la red](https://wiki.minix3.org/doku.php?id=usersguide:networkconfiguration)
6
+ * [SSH](https://wiki.minix3.org/doku.php?id=usersguide:settingupssh)
@@ -0,0 +1,19 @@
1
+ Vagrant.configure("2") do |config|
2
+ config.vm.define "vagrant-minix" do |i|
3
+ i.vm.box = "mcandre/minix"
4
+ i.vm.box_version = "0.0.1"
5
+
6
+ i.vm.hostname = "vagrant-minix"
7
+ #i.vm.network "public_network", bridge: [ "eth0" ]
8
+ #i.vm.network "public_network", bridge: [ "wlan0" ]
9
+ i.vm.network :forwarded_port, guest: 22, host: 2252
10
+ i.vm.synced_folder "./", "/vagrant"
11
+ i.vm.provision "shell", inline: <<-SHELL
12
+ hostname
13
+ SHELL
14
+ i.vm.provider "virtualbox" do |v|
15
+ v.name = 'vagrant-minix'
16
+ v.memory = 2048
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ .vagrant
2
+ *.log
3
+ *.box
4
+ private*
@@ -0,0 +1,25 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.define "vagrant-opensuse" do |i|
6
+ # Configure BOX
7
+ i.vm.box = "generic/opensuse15"
8
+
9
+ # Configure VM
10
+ i.vm.hostname = "vagrant-opensuse"
11
+ # i.vm.network "public_network", bridge: [ "eth0" ]
12
+ # i.vm.network "public_network", bridge: [ "wlan0" ]
13
+ i.vm.network :forwarded_port, guest: 22, host: 2222
14
+ i.vm.network :forwarded_port, guest: 22, host: 2231
15
+ i.vm.synced_folder "./", "/vagrant"
16
+ i.vm.provision "shell", path: 'install-software.sh'
17
+
18
+ # Configure VIRTUALBOX
19
+ i.vm.provider "virtualbox" do |v|
20
+ v.name = 'vagrant-opensuse'
21
+ v.memory = 2048
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1 @@
1
+ .vagrant
@@ -0,0 +1,20 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ config.vm.define "opensuse-kde" do |i|
6
+ i.vm.box = "microlinux/opensuse-15.3-kde"
7
+ i.vm.hostname = "kde42"
8
+ #i.vm.network "public_network", bridge: [ "eth1" ]
9
+ i.vm.network :forwarded_port, guest: 22, host: 2232
10
+ i.vm.synced_folder "./", "/vagrant"
11
+ i.vm.provision "shell", inline: <<-SHELL
12
+ zypper refresh
13
+ zypper in -y vim tree nmap
14
+ SHELL
15
+ i.vm.provider "virtualbox" do |v|
16
+ v.name = 'opensuse-kde'
17
+ v.memory = 2048
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,2 @@
1
+ .vagrant
2
+ *.log
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ text = <<-TEXT
4
+ apt install -y vim tree nmap
5
+ apt install -y git
6
+ apt install -y figlet
7
+
8
+ figlet ubuntu > /etc/motd
9
+ echo "" >> /etc/motd
10
+ echo "David Vargas Ruiz" >> /etc/motd
11
+ echo "https://github.com/dvarrui" >> /etc/motd
12
+
13
+ echo "# Adding more alias" >> /home/vagrant/.bashrc
14
+ echo "alias c='clear'" >> /home/vagrant/.bashrc
15
+ echo "alias v='vdir'" >> /home/vagrant/.bashrc
16
+
17
+ lsb_release -d
18
+ TEXT
19
+
20
+ lines = text.split("\n")
21
+ total = lines.size
22
+ lines.each_with_index do |line, index|
23
+ print "=" * 10
24
+ print " [ INFO ] Step #{index + 1}/#{total}"
25
+ puts "=" * 10
26
+ system(line)
27
+ end
@@ -0,0 +1,27 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ HOSTNAME = "vagrant-ubuntu"
5
+ Vagrant.configure("2") do |config|
6
+ config.vm.define HOSTNAME do |i|
7
+ # Configure box
8
+ i.vm.box = "ubuntu/focal64"
9
+
10
+ # Configure VM
11
+ i.vm.hostname = HOSTNAME
12
+ # i.vm.network "public_network", bridge: [ "eth0" ]
13
+ # i.vm.network "public_network", bridge: [ "wlan0" ]
14
+ i.vm.network :forwarded_port, guest: 22, host: 2242
15
+ i.vm.synced_folder "./", "/vagrant"
16
+ # i.vm.provision "shell", path: 'install-software.sh'
17
+ i.vm.provision "shell", inline: "apt-get update"
18
+ i.vm.provision "shell", inline: "apt-get install -y ruby"
19
+ i.vm.provision "shell", path: "install-software.rb"
20
+
21
+ # Configure provider
22
+ i.vm.provider "virtualbox" do |v|
23
+ v.name = HOSTNAME
24
+ v.memory = 2048
25
+ end
26
+ end
27
+ end