Move initscript to the right place, Fix return values from initscript according to guidelines

This commit is contained in:
Vitezslav Crhonek 2010-09-13 16:33:06 +02:00
parent f23808cc97
commit 6091aaca73
2 changed files with 75 additions and 4 deletions

View File

@ -0,0 +1,64 @@
diff -up openwsman-2.2.3/etc/init/openwsmand.sh.in.orig openwsman-2.2.3/etc/init/openwsmand.sh.in
--- openwsman-2.2.3/etc/init/openwsmand.sh.in.orig 2010-09-06 15:49:57.000000000 +0200
+++ openwsman-2.2.3/etc/init/openwsmand.sh.in 2010-09-13 15:09:17.823620695 +0200
@@ -19,13 +19,13 @@
NAME=openwsmand
DAEMON=/usr/sbin/$NAME
OPTIONS=-S # with SSL
-PIDFILE=/var/run/$NAME.pid
+PIDFILE=/var/run/wsmand.pid
lsb=0
if [ $EUID != 0 ]; then
echo "This script must be run as root."
- exit 1;
+ exit 4;
fi
if [ "$DESCRIPTIVE" = "" ]; then
@@ -65,6 +65,7 @@ start()
echo "NOTE: The script uses /dev/random device for generating some random bits while generating the server key."
echo -e " If this takes too long, you can replace the value of \"RANDFILE\" in @SYSCONFDIR@/ssleay.cnf with /dev/urandom.\n Please understand the implications of doing do."
+ exit 6 # Six means "program is not configured", seems to be suitable value
fi
fi
@@ -103,6 +104,9 @@ case "$1" in
stop)
stop
rm -f $lockfile
+ # pid file should be removed by server itself, but it's marked as
+ # TODO in wsmand.c source file;)
+ rm -f $PIDFILE
;;
restart)
@@ -136,7 +140,16 @@ case "$1" in
if [ $? -eq 0 ]; then
echo " running"
else
- echo " stopped"
+ if [ -e $PIDFILE ]; then
+ echo " stopped, but pid file exists"
+ exit 1
+ elif [ -e $lockfile ]; then
+ echo " stopped, but lock file exists"
+ exit 2
+ else
+ echo " stopped"
+ exit 3
+ fi
fi
fi
;;
@@ -147,6 +160,8 @@ case "$1" in
*)
echo "Usage: $0 {restart|start|stop|reload|force-reload|status}"
+ [ "$1" = "usage" ] && exit 0
+ exit 2
esac
if [ $lsb -ne 0 ]; then

View File

@ -28,6 +28,7 @@ Patch1: %{name}-randfile.patch
Patch2: %{name}-authors.patch
Patch3: %{name}-swig-ver-check.patch
Patch4: %{name}-sitelibdir.patch
Patch5: openwsman-2.2.3-initscript.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXXX)
%description
@ -143,6 +144,7 @@ This package provides Perl bindings to access the openwsman client API.
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1 -b .initscript
%build
sh autoconfiscate.sh
@ -171,8 +173,9 @@ rm -f %{buildroot}/%{_libdir}/openwsman/authenticators/*.la
mkdir -p %{buildroot}/%{_sysconfdir}/init.d
install -m 644 etc/openwsman.conf %{buildroot}/%{_sysconfdir}/openwsman
install -m 644 etc/ssleay.cnf %{buildroot}/%{_sysconfdir}/openwsman
install -m 755 etc/init/openwsmand.sh %{buildroot}/%{_sysconfdir}/init.d/openwsmand
ln -sf %{_sysconfdir}/init.d/openwsmand %{buildroot}/%{_sbindir}/rcopenwsmand
mkdir -p %{buildroot}/%{_sysconfdir}/rc.d/init.d
install -m 755 etc/init/openwsmand.sh %{buildroot}/%{_sysconfdir}/rc.d/init.d/openwsmand
ln -sf %{_sysconfdir}/rc.d/init.d/openwsmand %{buildroot}/%{_sbindir}/rcopenwsmand
%clean
rm -rf %{buildroot}
@ -183,7 +186,7 @@ rm -rf %{buildroot}
%post server
/sbin/ldconfig
chkconfig --add openwsmand
/sbin/chkconfig --add openwsmand
%preun server
if [ $1 = 0 ] ; then
@ -248,7 +251,7 @@ fi
%config(noreplace) %{_sysconfdir}/openwsman/ssleay.cnf
%attr(0755,root,root) %{_sysconfdir}/openwsman/owsmangencert.sh
%config(noreplace) %{_sysconfdir}/pam.d/openwsman
%attr(0755,root,root) %{_sysconfdir}/init.d/openwsmand
%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/openwsmand
%dir %{_libdir}/openwsman
%dir %{_libdir}/openwsman/authenticators
%{_libdir}/openwsman/authenticators/*.so
@ -268,6 +271,10 @@ fi
%changelog
* Mon Sep 13 2010 Vitezslav Crhonek <vcrhonek@redhat.com> - 2.2.3-8
- Move initscript to the right place
- Fix return values from initscript according to guidelines
* Tue Aug 10 2010 Praveen K Paladugu <praveen_paladugu@dell.com> - 2.2.3-7
- Moved the certificate generation from init script. The user will have to
- generate the certificate manually.