2008-02-28 10:37:06 -06:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation; version 2 only
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# IPA control to start/stop the various services required for IPA in the
|
|
|
|
# proper order
|
|
|
|
#
|
|
|
|
|
2010-08-31 16:28:41 -05:00
|
|
|
# Set IFS so we can do space-embedded lists of services
|
|
|
|
IFS=";"
|
|
|
|
|
|
|
|
# start and stop are basically a reverse of each other
|
|
|
|
services_stop="ipa_kpasswd;httpd;krb5kdc;dirsrv;ntpd;named;pki-cad pki-ca"
|
|
|
|
services_start="dirsrv;ntpd;named;krb5kdc;ipa_kpasswd;httpd;pki-cad pki-ca"
|
|
|
|
|
|
|
|
function is_running() {
|
|
|
|
# $1 = service to check on
|
|
|
|
# $2 = optional instance to check on, for dirsrv and pki-cad
|
2010-01-11 09:23:16 -06:00
|
|
|
|
2010-08-31 16:28:41 -05:00
|
|
|
# Returns
|
|
|
|
# 0 - running
|
|
|
|
# 1 - pid but dead service
|
|
|
|
# 2 - dead but locked subsys
|
|
|
|
# 3 - stopped
|
|
|
|
# 4 - no such service
|
|
|
|
if [ "$#" = 2 ] ; then
|
|
|
|
/sbin/service $1 status $2 > /dev/null 2>&1
|
|
|
|
else
|
|
|
|
out=`/sbin/service $1 status 2>&1`
|
2010-01-11 09:23:16 -06:00
|
|
|
fi
|
2010-08-31 16:28:41 -05:00
|
|
|
case "$?" in
|
|
|
|
0)
|
|
|
|
return 0;;
|
|
|
|
1)
|
|
|
|
x=`echo $out | grep -c exists`
|
|
|
|
if [ $x -eq 1 ] ; then
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 4
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
return 2;;
|
|
|
|
3)
|
|
|
|
return 3;;
|
|
|
|
esac
|
2008-02-28 10:37:06 -06:00
|
|
|
}
|
|
|
|
|
2010-08-31 16:28:41 -05:00
|
|
|
function start() {
|
|
|
|
for service in $services_start ; do
|
|
|
|
is_running $service
|
|
|
|
case "$?" in
|
|
|
|
0) # running
|
|
|
|
;;
|
|
|
|
4) # no such service
|
|
|
|
;;
|
|
|
|
*) # otherwise not running
|
|
|
|
/sbin/service $service start
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
2010-01-11 09:23:16 -06:00
|
|
|
|
2010-08-31 16:28:41 -05:00
|
|
|
function stop() {
|
|
|
|
for service in $services_stop ; do
|
|
|
|
is_running $service
|
|
|
|
case "$?" in
|
|
|
|
0) # running
|
|
|
|
/sbin/service $service stop
|
|
|
|
;;
|
|
|
|
*) # otherwise not running or doesn't exist
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2008-02-28 10:37:06 -06:00
|
|
|
}
|
|
|
|
|
2010-02-03 15:31:36 -06:00
|
|
|
function status() {
|
2010-08-31 16:28:41 -05:00
|
|
|
for service in $services_start ; do
|
|
|
|
is_running $service
|
|
|
|
case "$?" in
|
|
|
|
4)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
/sbin/service $service status
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2010-02-03 15:31:36 -06:00
|
|
|
}
|
|
|
|
|
2008-02-28 10:37:06 -06:00
|
|
|
case "$1" in
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
2010-02-03 15:31:36 -06:00
|
|
|
status)
|
|
|
|
status
|
|
|
|
;;
|
2008-02-28 10:37:06 -06:00
|
|
|
*)
|
2010-02-03 15:31:36 -06:00
|
|
|
echo "Usage: ipactl {start|stop|restart|status}"
|
2008-02-28 10:37:06 -06:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|