Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue by determining Linux flavor based on OS-specific file. #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 12 additions & 31 deletions lib/systemv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,18 @@ var mu = require('mu2'),
p = require('path'),
fs = require('fs'),
exec = require('child_process').exec,
supportedos = ['debian','centos','redhat','fedora','ubuntu','amzn'];
linuxFlavorCommand = "[ ! -e /etc/redhat-release ]; echo $?";


// Collapse the supported linux flavors down to just redhat and debian
// Determine Linux flavor from existence of "/etc/redhat-release" file
var getLinuxFlavor = function(stdout) {
var _os = supportedos.filter(function(i){
return stdout.indexOf(i) >= 0;
})[0];

switch(_os){
// Use RedHat for CentOS
case 'centos':
case 'fedora':
case 'amzn':
case 'redhat':
_os = 'redhat';
break;

// Use debian for Ubuntu & default
case 'ubuntu':
case 'debian':
default:
_os = 'debian';
break;
// Use Debian by default (or "/etc/debian-version" file exists)
var _os = 'debian';

stdout = stdout.trim();
if (stdout === '1') {
_os = 'redhat';
}

return _os;
};

Expand Down Expand Up @@ -109,9 +96,7 @@ var init = function(config){
callback = callback || function(){};

var me = this;
exec('cat /proc/version',function(error, stdout, stderr){
stdout = stdout.toLowerCase();

exec(linuxFlavorCommand, function(error, stdout, stderr){
var _os = getLinuxFlavor(stdout);

/**
Expand Down Expand Up @@ -358,9 +343,7 @@ var init = function(config){
}
var me = this;

exec('cat /proc/version',function(error, stdout, stderr){
stdout = stdout.toLowerCase();

exec(linuxFlavorCommand, function(error, stdout, stderr){
var _os = getLinuxFlavor(stdout);
var cmd;
if (_os === 'debian') {
Expand Down Expand Up @@ -401,9 +384,7 @@ var init = function(config){
return;
}
var me = this;
exec('cat /proc/version',function(error, stdout, stderr){
stdout = stdout.toLowerCase();

exec(linuxFlavorCommand, function(error, stdout, stderr){
var _os = getLinuxFlavor(stdout);
var cmd;
if (_os === 'debian') {
Expand Down