olds/easy-debian-init.rb
def check_os_version(os)
      cat = '/bin/cat'
      debian_version = '/etc/debian_version'
      centos_version = '/etc/redhat-relase'

      os_availables = %w(debian centos)
      if os_availables.include?(os.downcase)
        if os == 'debian'
          if File.exists?(debian_version)
            os_version = `#{cat} #{debian_version}`.chomp[/\d+/]
            case os_version
              when '7'
                return os_version_name = 'wheezy'
              when '8'
                return os_version_name = 'jessie'
              else
                puts "#{Tty.red}The Debian given does not have support yet! #{Tty.reset}"
            end
          else
            puts "#{Tty.red}The #{Tty.white}#{debian_version}#{Tty.red} does not exists! #{Tty.reset}"
          end
        elsif os == 'centos'
          if File.exists?(centos_version)
            os_version_name = `#{cat} #{centos_version}`.chomp[/\d+/]
          else
            puts "#{Tty.red}The #{Tty.white}#{centos_version}#{Tty.red} does not exists! #{Tty.reset}"
          end
        end
      else
        puts "#{Tty.red}The OS given does not have support yet! #{Tty.reset}"
      end
      return os_version_name
    end
# Method to get the OS version, it will be used for the another scripts
Method to get the OS version, it will be used for the another scripts
Method to get the OS version it will be used for the another scripts
def check_os_version(os)
      cat = '/bin/cat'
      debian_version = '/etc/debian_version'
      centos_version = '/etc/redhat-relase'
      os_availables = %w(debian centos)
      if os_availables.include?(os.downcase)
        if os == 'debian'
          if File.exists?(debian_version)
            os_version = `#{cat} #{debian_version}`.chomp[/\d+/]
            case os_version
              when '7'
                return os_version_name = 'wheezy'
              when '8'
                return os_version_name = 'jessie'
              else
                puts "#{Tty.red}The Debian given does not have support yet! #{Tty.reset}"
            end
          else
            puts "#{Tty.red}The #{Tty.white}#{debian_version}#{Tty.red} does not exists! #{Tty.reset}"
          end
        elsif os == 'centos'
          if File.exists?(centos_version)
            os_version_name = `#{cat} #{centos_version}`.chomp[/\d+/]
          else
            puts "#{Tty.red}The #{Tty.white}#{centos_version}#{Tty.red} does not exists! #{Tty.reset}"
          end
        end
      else
        puts "#{Tty.red}The OS given does not have support yet! #{Tty.reset}"
      end
      return os_version_name
    end
def check_os_version ( os ) cat = '/bin/cat' debian_version = '/etc/debian_version' centos_version = '/etc/redhat-relase' os_availables = %w( debian centos ) if os_availables . include? ( os . downcase ) if os == 'debian' if File . exists? ( debian_version ) os_version = ` #{ cat } #{ debian_version } ` . chomp [ / \d + / ] case os_version when '7' return os_version_name = 'wheezy' when '8' return os_version_name = 'jessie' else puts "#{Tty.red}The Debian given does not have support yet! #{Tty.reset}" end else puts "#{Tty.red}The #{Tty.white}#{debian_version}#{Tty.red} does not exists! #{Tty.reset}" end elsif os == 'centos' if File . exists? ( centos_version ) os_version_name = ` #{ cat } #{ centos_version } ` . chomp [ / \d + / ] else puts "#{Tty.red}The #{Tty.white}#{centos_version}#{Tty.red} does not exists! #{Tty.reset}" end end else puts "#{Tty.red}The OS given does not have support yet! #{Tty.reset}" end return os_version_name end
Method to get the OS version, it will be used for the another scripts
Method to get the OS version it will be used for the another scripts
os