Permalink
Browse files

Bug 864109 - [RFE] Remove `aeolus-restart-services`, `aeolus-check-se…

…rvices`

and enhance `aeolus-services {start|stop|restart|status}`

Add status action to aeolus-services, and add exit_status to properly reflect
success/failure of action in executing aeolus-services.
  • Loading branch information...
eggmaster committed Oct 19, 2012
1 parent 84fb816 commit 3e0b592de618a5da86e86b7fb89583dec46cb01f
View
@@ -1,44 +0,0 @@
-#!/usr/bin/ruby
-
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-if ARGV.include?('-h') || ARGV.include?('--help')
- puts "Usage: #{$0} [OPTION]
-Show status of Aeolus services.
-
- -h, --help display this help and exit
-
-To restart aeolus services please use aeolus-restart-services.
-"
-
- exit
-end
-
-# ordered as in rc.d
-init_scripts=%w(mongod iwhd postgresql httpd deltacloud-core libvirtd aeolus-conductor conductor-delayed_job conductor-dbomatic imagefactory ntpd)
-
-exit_status = 0
-init_scripts.each do |script|
- puts "\nChecking #{script} ..."
- cmd = "service #{script} status"
- out = `#{cmd}`
- if $?.to_i == 0
- puts " \e[1;32mSuccess\e[0m"
- else
- exit_status = 1
- puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
- end
-end
-exit(exit_status)
@@ -1,60 +0,0 @@
-#!/usr/bin/ruby
-
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-if ARGV.include?('-h') || ARGV.include?('--help')
- puts "Usage: #{$0} [OPTION]
-Restart Aeolus services.
-
- -h, --help display this help and exit
-
-To show status of aeolus services please use aeolus-check-services.
-"
-
- exit
-end
-
-# ordered as in rc.d
-services = %w(mongod iwhd postgresql httpd deltacloud-core libvirtd aeolus-conductor conductor-delayed_job conductor-dbomatic imagefactory ntpd)
-
-def perform(action, svcs)
- action = action.to_s
- svcs.map do |script|
- cmd = "service #{script} #{action}"
- puts "\n# #{cmd} ..."
- out = `#{cmd}`
- if $?.to_i == 0
- puts " \e[1;32mSuccess\e[0m"
- else
- puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
- end
- $?.to_i
- end
-end
-
-perform :stop, services.reverse
-perform :start, services
-
-## Other checks
-
-if perform(:status, ['mongod']) == [1]
- lockfile = '/var/lib/mongodb/mongod.lock'
- if File.exists?(lockfile)
- puts " \e[1;33mremoving\e[0m leftover #{lockfile}"
- File.delete(lockfile)
- perform :restart, %w(mongod iwhd)
- end
-end
-
View
@@ -15,21 +15,17 @@
# limitations under the License.
if ARGV.include?('-h') || ARGV.include?('--help')
- puts "Usage: #{$0} stop|start|restart
-Stop, Start, or Restart Aeolus services.
+ puts "Usage: #{$0} stop|start|restart|status
+Stop, Start, Restart, or display Status of Aeolus services.
-h, --help display this help and exit
-
-To show status of aeolus services please use aeolus-check-services.
"
exit
end
-if !['stop','start','restart'].include?(ARGV[0])
+if !['stop','start','restart','status'].include?(ARGV[0])
puts "Usage: #{$0} stop|start|restart
-Stop, Start, or Restart Aeolus services.
-
-To show status of aeolus services please use aeolus-check-services.
+Stop, Start, Restart, or display Status of Aeolus services.
"
exit(1)
end
@@ -40,6 +36,7 @@ $services = %w(mongod iwhd postgresql httpd deltacloud-core libvirtd aeolus-cond
$action_messages = {'status' => 'Checking status of',
'start' => 'Starting',
'stop' => 'Stopping'}
+$exit_status = 0
def perform(action, svcs)
action = action.to_s
@@ -50,6 +47,7 @@ def perform(action, svcs)
if $?.to_i == 0
puts " \e[1;32mSuccess\e[0m"
else
+ $exit_status = 1
puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
end
$?.to_i
@@ -81,8 +79,15 @@ def restart
start
end
+def status
+ perform :status, $services
+end
+
case ARGV[0]
when "start" then start
when "stop" then stop
when "restart" then restart
+ when "status" then status
end
+
+exit $exit_status
@@ -49,8 +49,6 @@ Aeolus Configure Puppet Recipe
%{__cp} -R %{pbuild}/recipes/postgres/ %{buildroot}/%{aeolushome}/modules/postgres
%{__cp} -R %{pbuild}/bin/aeolus-node %{buildroot}/%{aeolushome}/modules/aeolus/
%{__cp} -R %{pbuild}/bin/aeolus-node-check %{buildroot}/%{aeolushome}/modules/aeolus/
-%{__cp} -R %{pbuild}/bin/aeolus-check-services %{buildroot}/%{_bindir}/
-%{__cp} -R %{pbuild}/bin/aeolus-restart-services %{buildroot}/%{_sbindir}/
%{__cp} -R %{pbuild}/bin/aeolus-services %{buildroot}/%{_sbindir}/
%{__cp} -R %{pbuild}/bin/aeolus-configure %{buildroot}/%{_sbindir}/
%{__cp} -R %{pbuild}/bin/aeolus-cleanup %{buildroot}/%{_sbindir}/
@@ -62,8 +60,6 @@ Aeolus Configure Puppet Recipe
%attr(0755, root, root) %{_sbindir}/aeolus-cleanup
%config(noreplace) %{_sysconfdir}/aeolus-configure/*
%attr(0600, root, root) %{_sysconfdir}/aeolus-configure/nodes/*
-%attr(0755, root, root) %{_bindir}/aeolus-check-services
-%attr(0755, root, root) %{_sbindir}/aeolus-restart-services
%attr(0755, root, root) %{_sbindir}/aeolus-services
%doc %{_mandir}/man1/*
%{aeolushome}
@@ -1,18 +0,0 @@
-.\" Originally generated by help2man 1.40.4, modified since.
-.TH AEOLUS-CHECK-SERVICES "1" "March 2012" "aeolus-check-services " "User Commands"
-.SH NAME
-aeolus-check-services \- manual page for aeolus-check-services
-.SH SYNOPSIS
-.B aeolus-check-services
-[\fIOPTION\fR]
-.SH DESCRIPTION
-Show status of Aeolus services.
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-display this help and exit
-.PP
-To restart aeolus services please use aeolus\-restart\-services.
-.SH "SEE ALSO"
-The full documentation for
-.B aeolus-check-services
-is maintained at http://www.aeolusproject.org.
@@ -1,18 +0,0 @@
-.\" Originally generated by help2man 1.40.4, modified since.
-.TH AEOLUS-RESTART-SERVICES "1" "March 2012" "aeolus-restart-services " "User Commands"
-.SH NAME
-aeolus-restart-services \- manual page for aeolus-restart-services
-.SH SYNOPSIS
-.B aeolus-restart-services
-[\fIOPTION\fR]
-.SH DESCRIPTION
-Restart Aeolus services.
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-display this help and exit
-.PP
-To show status of aeolus services please use aeolus\-check\-services.
-.SH "SEE ALSO"
-The full documentation for
-.B aeolus-restart-services
-is maintained at http://www.aeolusproject.org.
@@ -7,14 +7,12 @@ aeolus-services \- manual page for aeolus-services
[\fIOPTION\fR]
.SH DESCRIPTION
USAGE:
-aeolus\-services [\-h|\-\-help] stop|start|restart
+aeolus\-services [\-h|\-\-help] stop|start|restart|status
.PP
-Stop, Start, Restart Aeolus services.
+Stop, Start, Restart, or display Status of Aeolus services.
.TP
\fB\-h\fR, \fB\-\-help\fR
display this help and exit
-.PP
-To show status of aeolus services please use aeolus\-check\-services.
.SH "SEE ALSO"
The full documentation for
.B aeolus-services

0 comments on commit 3e0b592

Please sign in to comment.