Makefile | 3 +-
cas.spec | 14 +++++++++
startup/cas-server | 77 +++++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 85 insertions(+), 9 deletions(-)
New commits:
commit f0800d1cb672bae627d9c7fba92490bf6e5490a0
Author: adam stokes <astokes(a)fedoraproject.org>
Date: Mon May 24 11:09:26 2010 -0400
startup script
diff --git a/Makefile b/Makefile
index afdcf31..5bcacfb 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,8 @@ SUBDIRS = caslib \
contrib \
snippets \
overseer \
-overseer/static
+overseer/static \
+startup
PYFILES = $(wildcard *.py)
diff --git a/cas.spec b/cas.spec
index b74454e..7f12411 100644
--- a/cas.spec
+++ b/cas.spec
@@ -1,4 +1,5 @@
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%global _initdir %{_sysconfdir}/rc.d/init.d
Name: cas
Summary: Tool to analyze and configure core file environment
@@ -42,6 +43,9 @@ Requires: cas-admin = %{version}-%{release}
Requires: python-cherrypy
Requires: python-simplejson
Requires: python-mako
+Requires(post): /sbin/chkconfig
+Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
%description server
Provides web frontend to CAS to allow for a much simpler user experience when
@@ -61,6 +65,15 @@ for i in `find ${RPM_BUILD_ROOT} -iname Makefile`; do rm $i; done
%clean
rm -rf ${RPM_BUILD_ROOT}
+%post
+/sbin/chkconfig --add %{name}
+
+%preun
+if [ $1 = 0 ]; then
+ /sbin/service %{name} stop > /dev/null 2>&1
+ /sbin/chkconfig --del %{name}
+fi
+
%files
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/cas.conf
@@ -81,6 +94,7 @@ rm -rf ${RPM_BUILD_ROOT}
%defattr(-,root,root,-)
%{_datadir}/%{name}/overseer
%{_bindir}/cas-server
+%{_initdir}/cas-server
%changelog
* Tue May 20 2010 Adam Stokes <ajs at redhat dot com> - 1.0
diff --git a/startup/cas-server b/startup/cas-server
index f679c40..81f158b 100755
--- a/startup/cas-server
+++ b/startup/cas-server
@@ -21,24 +21,85 @@ prog="cas-server"
# function library
. /etc/rc.d/init.d/functions
-start () {}
-stop() {}
-restart() {}
-status() {}
+# check config
+[ -f /etc/cas.conf ] || exit 0
+# bin
+CASSERVER="/usr/bin/cas-server"
+
+RETVAL=0
+
+getpid() {
+ pid=`ps -eo pid,comm | grep cas- | awk '{ print $1 }'`
+}
+
+start () {
+ echo -n "Starting $prog: "
+ getpid
+ if [ -z "$pid" ]; then
+ $CASSERVER 2> /dev/null
+ RETVAL=$?
+ fi
+ if [ $RETVAL eq 0 ]; then
+ touch /var/lock/subsys/cas-server
+ echo_success
+ else
+ echo_failure
+ fi
+ echo
+ return $RETVAL
+}
+
+stop() {
+ echo -n "Stopping $prog: "
+ getpid
+ RETVAL=$?
+ if [ -n "$pid" ]; then
+ killproc $pid
+ sleep 1
+ getpid
+ if [ -z "$pid" ]; then
+ rm -f /var/lock/subsys/cas-server
+ echo_success
+ else
+ echo_failure
+ fi
+ else
+ echo_failure
+ fi
+ echo
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
+}
+
+status() {
+ getpid
+ if [ -n "$pid" ]; then
+ echo "$prog is running ..."
+ else
+ RETVAL=1
+ echo "$prog is stopped"
+ fi
+ return $RETVAL
+}
case "$1" in
start)
- $1
+ start
;;
stop)
- $1
+ stop
;;
restart)
- $1
+ restart
;;
status)
- $1
+ status $prog
+ ret=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|}"