From 1821c13252c859e8317536c411cab87f60c40d03 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 19 Jun 2008 14:26:47 +0000 Subject: [PATCH] -Rework init script to be more robust and SLES/RH agnostic --- conserver/conserver.spec | 2 +- conserver/initscript.patch | 101 +++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 5 deletions(-) diff --git a/conserver/conserver.spec b/conserver/conserver.spec index eb507f9..ab96966 100644 --- a/conserver/conserver.spec +++ b/conserver/conserver.spec @@ -11,7 +11,7 @@ # hostname (console) %define master console -%define distver 5 +%define distver 6 Summary: Serial console server daemon/client Name: %{pkg} diff --git a/conserver/initscript.patch b/conserver/initscript.patch index 175ac11..fa44289 100644 --- a/conserver/initscript.patch +++ b/conserver/initscript.patch @@ -1,12 +1,105 @@ diff -urN conserver-8.1.16/contrib/redhat-rpm/conserver.init conserver-8.1.16-diffinit/contrib/redhat-rpm/conserver.init --- conserver-8.1.16/contrib/redhat-rpm/conserver.init 2003-02-27 21:06:50.000000000 -0500 -+++ conserver-8.1.16-diffinit/contrib/redhat-rpm/conserver.init 2008-05-07 15:56:06.000000000 -0400 -@@ -24,7 +24,7 @@ ++++ conserver-8.1.16-diffinit/contrib/redhat-rpm/conserver.init 2008-06-19 10:24:49.000000000 -0400 +@@ -6,15 +6,38 @@ + # description: conserver is a serial-port console daemon + # config: /etc/conserver.cf + # ++MStatus() ++{ ++ ps ax|grep -v grep|grep conserver >& /dev/null ++ if [ "$?" = "0" ]; then ++ RVAL=0 ++ echo "conserver is running" ++ else ++ RVAL=3 ++ echo "consever is not running" ++ fi ++ return $RVAL ++} + +-# Source function library. +-. /etc/rc.d/init.d/functions +- +-# Source networking configuration. +-. /etc/sysconfig/network + +-# Check that networking is up. +-[ ${NETWORKING} = "no" ] && exit 0 ++# Source function library. ++if [ -f /etc/rc.d/init.d/functions ]; then ++ . /etc/rc.d/init.d/functions ++ DAEMON=daemon ++ SUCCESS=success ++ FAILURE=failure ++ PASSED=passed ++ STATUS=status ++elif [ -f /lib/lsb/init-functions ]; then ++ . /lib/lsb/init-functions ++ DAEMON=start_daemon ++ SUCCESS=log_success_msg ++ FAILURE=log_failure_msg ++ PASSED=log_warning_msg ++ STATUS=MStatus ++else ++ echo "Error, not RedHat and not lsb, do not know how to run this platform" ++fi + + # make sure conserver is installed and executable + [ -x /usr/sbin/conserver ] || exit 1 +@@ -24,22 +47,49 @@ case "$1" in start) echo -n "Starting conserver: " - daemon conserver -d -+ daemon conserver -o -O1 -d - echo +- echo ++ $DAEMON /usr/sbin/conserver -o -O1 -d touch /var/lock/subsys/conserver ++ $STATUS conserver >& /dev/null ++ if [ "$?" != "0" ]; then ++ $FAILURE ++ echo ++ exit 1 ++ fi ++ $SUCCESS ++ echo ;; + stop) ++ $STATUS conserver >& /dev/null ++ if [ "$?" != "0" ]; then ++ echo -n "conserver not running, not stopping " ++ $PASSED ++ echo ++ exit 1 ++ fi + echo -n "Shutting down conserver: " + killproc conserver +- echo + rm -f /var/lock/subsys/conserver ++ $STATUS conserver >& /dev/null ++ if [ "$?" == "0" ]; then ++ $FAILURE ++ echo ++ exit 1 ++ fi ++ $SUCCESS ++ echo + ;; + status) +- status conserver ++ $STATUS conserver + ;; + restart) +- echo -n "Restarting conserver: " +- killproc conserver -HUP ++ $STATUS conserver >& /dev/null ++ if [ "$?" != "0" ]; then ++ exec $0 start ++ else ++ echo -n "Restarting conserver: " ++ killproc conserver -HUP ++ fi ++ $SUCCESS + echo + ;; + *)