From e79db42a131f8f832521185ead81614ef341b416 Mon Sep 17 00:00:00 2001 From: Fumihisa TONAKA Date: Fri, 5 Jul 2013 06:55:39 +0900 Subject: [PATCH 1/2] fix check intalled and check_running for Solaris family. On Solaris 10 and 11, gnu grep is optional. Then check_installed and check_running use egrep (not gnu) in commands/solaris.rb and use gnu grep in commands/smartos.rb. --- lib/serverspec/commands/smartos.rb | 8 ++++++++ lib/serverspec/commands/solaris.rb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/serverspec/commands/smartos.rb b/lib/serverspec/commands/smartos.rb index 5fb00b02..8ace1b33 100644 --- a/lib/serverspec/commands/smartos.rb +++ b/lib/serverspec/commands/smartos.rb @@ -8,6 +8,14 @@ def check_installed(package, version=nil) end cmd end + + def check_enabled(service, level=3) + "svcs -l #{escape(service)} 2> /dev/null | grep -wx '^enabled.*true$'" + end + + def check_running(service) + "svcs -l #{escape(service)} status 2> /dev/null |grep -wx '^state.*online$'" + end end end end diff --git a/lib/serverspec/commands/solaris.rb b/lib/serverspec/commands/solaris.rb index 81b50ee2..27267a7e 100644 --- a/lib/serverspec/commands/solaris.rb +++ b/lib/serverspec/commands/solaris.rb @@ -2,7 +2,7 @@ module Serverspec module Commands class Solaris < Base def check_enabled(service, level=3) - "svcs -l #{escape(service)} 2> /dev/null | grep -wx '^enabled.*true$'" + "svcs -l #{escape(service)} 2> /dev/null | egrep '^enabled *true$'" end def check_installed(package, version=nil) @@ -19,7 +19,7 @@ def check_listening(port) end def check_running(service) - "svcs -l #{escape(service)} status 2> /dev/null |grep -wx '^state.*online$'" + "svcs -l #{escape(service)} status 2> /dev/null | egrep '^state *online$'" end def check_cron_entry(user, entry) From 402b31a11031d225f847125053fd4ca2d33acb2e Mon Sep 17 00:00:00 2001 From: Fumihisa TONAKA Date: Fri, 5 Jul 2013 07:03:13 +0900 Subject: [PATCH 2/2] update tests --- spec/solaris/commands_spec.rb | 4 ++-- spec/solaris10/commands_spec.rb | 4 ++-- spec/solaris11/commands_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/solaris/commands_spec.rb b/spec/solaris/commands_spec.rb index 8575be69..70447082 100644 --- a/spec/solaris/commands_spec.rb +++ b/spec/solaris/commands_spec.rb @@ -21,12 +21,12 @@ describe 'check_enabled' do subject { commands.check_enabled('httpd') } - it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" } + it { should eq "svcs -l httpd 2> /dev/null | egrep '^enabled *true$'" } end describe 'check_running' do subject { commands.check_running('httpd') } - it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" } + it { should eq "svcs -l httpd status 2> /dev/null | egrep '^state *online$'" } end describe 'check_belonging_group' do diff --git a/spec/solaris10/commands_spec.rb b/spec/solaris10/commands_spec.rb index 074f1724..d279eedc 100644 --- a/spec/solaris10/commands_spec.rb +++ b/spec/solaris10/commands_spec.rb @@ -20,12 +20,12 @@ describe 'check_enabled' do subject { commands.check_enabled('httpd') } - it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" } + it { should eq "svcs -l httpd 2> /dev/null | egrep '^enabled *true$'" } end describe 'check_running' do subject { commands.check_running('httpd') } - it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" } + it { should eq "svcs -l httpd status 2> /dev/null | egrep '^state *online$'" } end describe 'check_belonging_group' do diff --git a/spec/solaris11/commands_spec.rb b/spec/solaris11/commands_spec.rb index 196153a2..f1b1ece3 100644 --- a/spec/solaris11/commands_spec.rb +++ b/spec/solaris11/commands_spec.rb @@ -21,12 +21,12 @@ describe 'check_enabled' do subject { commands.check_enabled('httpd') } - it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" } + it { should eq "svcs -l httpd 2> /dev/null | egrep '^enabled *true$'" } end describe 'check_running' do subject { commands.check_running('httpd') } - it { should eq "svcs -l httpd status 2> /dev/null |grep -wx '^state.*online$'" } + it { should eq "svcs -l httpd status 2> /dev/null | egrep '^state *online$'" } end describe 'check_belonging_group' do