Fork me on GitHub

Лупайте сю скалу...

Іван Франко


 RSS | Atom

19 June 2015

TOP »

Selected projects See all »

Banalize: Bash static code analyzerDBIx::Report::ExcelShell settings, AKA dotfilesNagios Monitoring for Couchbase serverNagira: RESTful API for NagiosStartpack for Github pages developmentWeb iPhoto

Travel Blog Витрішки »

Україномовний блог Витрішки - блог про все, крім роботи. Цикл статей "Літо на півночі Японії" з цього блогу тепер опублікований у Витрішках

Computer Blog All posts »

iPhoto and files permission Is MacOSX 10.9 == MacOS 9.x? Running Chef roles from Capistrano und Capiche Github & Jekyll: Speeding up Jekyll siteGithub & Jekyll: More experience with Jekyll and setup changesBuild new hosts with Capistrano and Chef Request Tracker: More about custom CSS for RT4Ruby 2 test drive Nagira v0.2.5 release It's UNIX my dear Watson

Slides See all »

Nagira @TLUG, 2012Rspec and Guard

About

Ярило Yarylo, Jarilo me @ github me @ CPAN Dmytro (CV)

It's UNIX my dear Watson

Summary: Shell script for detecting aspects of UNIX OS: version, Linux distribution, clone name, release .

In many shell scripts one can find pieces of code such as:

if [ grep -i centos /etc/redhat-release ]
then
   DISTRO=CentOS
else
   ...

and so on.

It's not difficult task to find what OS/ditsro you are running on, but sometimes it takes couple minutes to remember what is actually different between Debian and Ubuntu to make reliable guess. And it is a repeating task, meaning that couple minutes can be spent more than once.

Meet Sherlock OS

This is a simple shell script to detect UNIX/Linux OS and various aspects of the OS. Especially for Linux: distribution type and derivative (such as CentOS/RHEL or Debian/Ubuntu)

But it is packaged as real Ruby gem (I am mostly developing in Ruby these days), so installation is as simple as gem install sherlock_os. After you install it you can do it like:

$ sherlock
OS=Linux
MACH=x86_64
KERNEL=2.6.32-5-amd64
DISTRIBUTION=debian
FAMILY=debian
DERIVATIVE=Debian
RELEASE=6.0.6
CODENAME=squeeze

or even

$ eval `sherlock | grep DERIVATIVE`
$
$ echo DERIVATIVE
Debian

Documentation

Available at http://dmytro.github.com/sherlock_os

Source code

http://github.com/dmytro/sherlock_os

Enjoy!

Author

Dmytro Kovalov (dmytro.kovalov@gmail.com)

Source code






дмитро ковальов
dmytro @ github
dmytro.sytes.net