Fix initscript

This commit is contained in:
vcrhonek 2009-09-23 13:36:42 +00:00
parent f620561d3c
commit 77d41b37af
2 changed files with 116 additions and 69 deletions

View File

@ -1,7 +1,7 @@
diff -up pegasus/rpm/tog-pegasus.rc_old pegasus/rpm/tog-pegasus.rc diff -up pegasus/rpm/tog-pegasus.rc_old pegasus/rpm/tog-pegasus.rc
--- pegasus/rpm/tog-pegasus.rc_old 2008-12-02 10:00:03.000000000 +0100 --- pegasus/rpm/tog-pegasus.rc_old 2008-12-02 10:00:03.000000000 +0100
+++ pegasus/rpm/tog-pegasus.rc 2009-03-18 14:39:40.000000000 +0100 +++ pegasus/rpm/tog-pegasus.rc 2009-09-23 14:52:10.000000000 +0200
@@ -1,78 +1,108 @@ @@ -1,98 +1,153 @@
-#//%LICENSE//////////////////////////////////////////////////////////////// -#//%LICENSE////////////////////////////////////////////////////////////////
-#// -#//
-#// Licensed to The Open Group (TOG) under one or more contributor license -#// Licensed to The Open Group (TOG) under one or more contributor license
@ -72,113 +72,156 @@ diff -up pegasus/rpm/tog-pegasus.rc_old pegasus/rpm/tog-pegasus.rc
case "$1" in case "$1" in
start) start)
- echo -n $"Starting up CIM server: "
- $CIMSERVER_BIN
- RETVAL=$?
- [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start"
- echo
- ;;
+ if [[ $EUID -ne 0 ]]; then
+ echo "tog-pegasus $1: $CIMSERVER_BIN executed under nonprivileged user"
+ exit 4
+ fi
+ pid=`pidofproc $CIMSERVER_BIN` + pid=`pidofproc $CIMSERVER_BIN`
+ RETVAL=$? + RETVAL=$?
+ if [ "$RETVAL" -eq 0 ]; then + if [ "$RETVAL" -eq 0 ]; then
+ echo "tog-pegasus $1: $CIMSERVER_BIN is already running"; + echo "tog-pegasus $1: $CIMSERVER_BIN is already running"
+ exit 0; + exit 0
+ fi; + fi
+ +
+ if [ ! -e $CIMSERVER_BIN ]; then + if [ ! -e $CIMSERVER_BIN ]; then
+ echo "tog-pegasus $1: $CIMSERVER_BIN not found"; + echo "tog-pegasus $1: $CIMSERVER_BIN not found"
+ failure; + failure
+ exit 5; + exit 5
+ fi; + fi
+ +
+ if [ ! -x $CIMSERVER_BIN ]; then + if [ ! -x $CIMSERVER_BIN ]; then
+ echo "tog-pegasus $1: $CIMSERVER_BIN not executable"; + echo "tog-pegasus $1: $CIMSERVER_BIN not executable"
+ failure; + failure
+ exit 4; + exit 4
+ fi; + fi
+ +
+ if [ ! -e ${PEGASUS_SSL_CONF_FILE} ] || [ ! -e ${PEGASUS_SSL_CERT_FILE} ] || + if [ ! -e ${PEGASUS_SSL_CONF_FILE} ] || [ ! -e ${PEGASUS_SSL_CERT_FILE} ] ||
+ [ ! -e ${PEGASUS_SSL_KEY_FILE} ] || [ ! -e ${PEGASUS_SSL_TRUSTSTORE} ]; then + [ ! -e ${PEGASUS_SSL_KEY_FILE} ] || [ ! -e ${PEGASUS_SSL_TRUSTSTORE} ]; then
+ if [ -x /usr/share/Pegasus/scripts/genOpenPegasusSSLCerts ]; then + if [ -x /usr/share/Pegasus/scripts/genOpenPegasusSSLCerts ]; then
+ echo -n "tog-pegasus: Generating cimserver SSL certificates..."; + echo -n "tog-pegasus: Generating cimserver SSL certificates..."
+ /usr/share/Pegasus/scripts/genOpenPegasusSSLCerts; + /usr/share/Pegasus/scripts/genOpenPegasusSSLCerts
+ if [ $? -eq 0 ]; then + if [ $? -eq 0 ]; then
+ success; + success
+ else + else
+ failure; + failure
+ fi; + fi
+ echo; + echo
+ fi; + fi
+ fi; + fi
echo -n $"Starting up CIM server: " + echo -n $"Starting up CIM server: "
- $CIMSERVER_BIN
+ $CIMSERVER_BIN ${CIMSERVER_OPTIONS} + $CIMSERVER_BIN ${CIMSERVER_OPTIONS}
RETVAL=$? + RETVAL=$?
- [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start"
- echo
+ if [ "$RETVAL" -eq 0 ]; then + if [ "$RETVAL" -eq 0 ]; then
+ touch $LOCKFILE; + rm -f /var/run/tog-pegasus.pid;
+ success; + ln -s /var/run/tog-pegasus/"$prog".pid /var/run/tog-pegasus.pid;
+ touch $LOCKFILE
+ success
+ else + else
+ failure; + failure
+ fi; + fi
+ echo; + echo
;; + ;;
stop) stop)
echo -n $"Shutting down CIM server: " - echo -n $"Shutting down CIM server: "
killproc cimserver - killproc cimserver
RETVAL=$? - RETVAL=$?
- [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog stop" || log_failure_msg $"$prog stop" - [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog stop" || log_failure_msg $"$prog stop"
- echo - echo
- ;;
+ if [[ $EUID -ne 0 ]]; then
+ echo "tog-pegasus $1: $CIMSERVER_BIN executed under nonprivileged user"
+ exit 4
+ fi
+ echo -n $"Shutting down CIM server: "
+ killproc cimserver
+ RETVAL=$?
+ if [ "$RETVAL" -eq 0 ]; then + if [ "$RETVAL" -eq 0 ]; then
+ rm -f $LOCKFILE; + rm -f $LOCKFILE
+ rm -f /var/run/tog-pegasus/*; + rm -f /var/run/tog-pegasus/*
+ success; + rm -f /var/run/tog-pegasus.pid
+ success
+ else + else
+ failure; + failure
+ fi; + fi
+ echo; + echo
;; + ;;
+ +
status) status)
pid=`pidofproc $CIMSERVER_BIN` - pid=`pidofproc $CIMSERVER_BIN`
RETVAL=$? - RETVAL=$?
if [ "$RETVAL" -eq 0 ]; then - if [ "$RETVAL" -eq 0 ]; then
- echo "CIM server is running" - echo "CIM server is running"
+ echo -n $"CIM server ($pid) is running"; - else
+ RETVAL=0
else
- echo "CIM server is not running" - echo "CIM server is not running"
- fi - fi
+ echo -n $"CIM server is not running"; - ;;
+ RETVAL=3 + pid=`pidofproc $CIMSERVER_BIN`
+ fi; + RETVAL=$?
+ echo; + if [ "$RETVAL" -eq 0 ]; then
;; + echo -n $"CIM server ($pid) is running"
+ exit 0
+ else
+ if [ -e /var/run/tog-pegasus.pid ]; then
+ echo $"CIM server is not running, but pid file exists"
+ exit 1
+ elif [ -e $LOCKFILE ]; then
+ echo $"CIM server is not running, but lock file exists"
+ exit 2
+ else
+ echo $"CIM server is not running"
+ exit 3
+ fi
+ fi
+ echo
+ ;;
+ +
condrestart) condrestart)
pid=`pidofproc $CIMSERVER_BIN` - pid=`pidofproc $CIMSERVER_BIN`
RETVAL=$? - RETVAL=$?
@@ -81,18 +111,23 @@ case "$1" in - if [ "$RETVAL" -eq 0 ]; then
RETVAL=$?; - $0 stop && $0 start;
fi; - RETVAL=$?;
- fi;
+ pid=`pidofproc $CIMSERVER_BIN`
+ RETVAL=$?
+ if [ "$RETVAL" -eq 0 ]; then
+ $0 stop && $0 start
+ RETVAL=$?
+ fi;
;; ;;
+ +
try-restart) try-restart)
- $0 stop && $0 start - $0 stop && $0 start
+ $0 stop && $0 start; - ;;
+ RETVAL=$?; + $0 stop && $0 start
;; + RETVAL=$?
+ ;;
+ +
restart|force-reload) restart|force-reload)
- $0 stop - $0 stop
- $0 start - $0 start
+ $0 stop; - ;;
+ $0 start; + $0 stop
+ RETVAL=$?; + $0 start
;; + RETVAL=$?
+ ;;
+ +
reload) reload)
;; - ;;
+ ;;
*) *)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|try-restart}" - echo "Usage: $0 {start|stop|status|restart|reload|force-reload|try-restart}"
- exit 1 - exit 1
+ RETVAL=3 + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|try-restart}"
+ [ "$1" = "usage" ] && exit 0
+ exit 2
esac esac
exit $RETVAL exit $RETVAL

View File

@ -41,7 +41,7 @@
%endif %endif
Version: 2.9.0 Version: 2.9.0
Release: 6%{?dist} Release: 7%{?dist}
Epoch: 2 Epoch: 2
# #
Summary: OpenPegasus WBEM Services for Linux Summary: OpenPegasus WBEM Services for Linux
@ -463,6 +463,10 @@ fi
%changelog %changelog
* Wed Sep 23 2009 Vitezslav Crhonek <vcrhonek@redhat.com> - 2:2.9.0-7
- Fix initscript
Resolves: #523370
* Wed Sep 16 2009 Tomas Mraz <tmraz@redhat.com> - 2:2.9.0-6 * Wed Sep 16 2009 Tomas Mraz <tmraz@redhat.com> - 2:2.9.0-6
- Use password-auth common PAM configuration instead of system-auth - Use password-auth common PAM configuration instead of system-auth