[Pkg-ossec-devel] [pkg-ossec] 08/18: Return value instead of exitting with it.
Jose Antonio Quevedo Muñoz
jaqm-guest at alioth.debian.org
Tue Aug 13 15:24:52 UTC 2013
This is an automated email from the git hooks/post-receive script.
jaqm-guest pushed a commit to branch debian
in repository pkg-ossec.
commit a6d331db0a78f83d23cbf68c7e235749f752eefb
Author: Jose Antonio Quevedo <joseantonio.quevedo at gmail.com>
Date: Tue Aug 13 10:10:21 2013 +0200
Return value instead of exitting with it.
---
debian/patches/06-control-return-status-value | 465 +++++++++++++++++++++++--
1 file changed, 440 insertions(+), 25 deletions(-)
diff --git a/debian/patches/06-control-return-status-value b/debian/patches/06-control-return-status-value
index a568f5d..147a895 100644
--- a/debian/patches/06-control-return-status-value
+++ b/debian/patches/06-control-return-status-value
@@ -1,6 +1,95 @@
--- a/src/init/ossec-server.sh
+++ b/src/init/ossec-server.sh
-@@ -198,7 +198,7 @@
+@@ -5,15 +5,11 @@
+
+
+ # Getting where we are installed
+-[ -e /etc/ossec-init.conf ] && . /etc/ossec-init.conf # Source the configuration file for DIRECTORY
+-if [ -z "$DIRECTORY" ]; then
+- echo "ERROR: Cannot determine the value of the OSSEC directory"
+- [ ! -e "/etc/ossec-init.conf" ] && echo "ERROR: /etc/ossec-init.conf does not exist"
+- exit 1
+-fi
+ LOCAL=`dirname $0`;
+ cd ${LOCAL}
+-PLIST="${DIRECTORY}/bin/.process_list"
++PWD=`pwd`
++DIR=`dirname $PWD`;
++PLIST=${DIR}/bin/.process_list;
+
+
+ ### Do not modify bellow here ###
+@@ -32,8 +28,8 @@
+
+
+ ## Locking for the start/stop
+-LOCK="${DIRECTORY}/var/run/ossec-hids/"
+-LOCK_PID="${LOCK}/start-script-lock.pid"
++LOCK="${DIR}/var/start-script-lock"
++LOCK_PID="${LOCK}/pid"
+
+
+ # This number should be more than enough (even if it is
+@@ -47,11 +43,11 @@
+ checkpid()
+ {
+ for i in ${DAEMONS}; do
+- for j in `cat ${LOCK}/${i}*.pid 2>/dev/null`; do
++ for j in `cat ${DIR}/var/run/${i}*.pid 2>/dev/null`; do
+ ps -p $j |grep ossec >/dev/null 2>&1
+ if [ ! $? = 0 ]; then
+- echo "Deleting PID file '${LOCK}/${i}-${j}.pid' not used..."
+- rm ${LOCK}/${i}-${j}.pid
++ echo "Deleting PID file '${DIR}/var/run/${i}-${j}.pid' not used..."
++ rm ${DIR}/var/run/${i}-${j}.pid
+ fi
+ done
+ done
+@@ -66,14 +62,9 @@
+
+ # Providing a lock.
+ while [ 1 ]; do
+- [ ! -e "${LOCK}" ] && mkdir ${LOCK} > /dev/null 2>&1
+- # Ensure we can make the LOCK properly first
+- if [ ! -d "${LOCK}" ] ; then
+- echo "ERROR: The configured lock directory ${LOCK} is not a directory or it does not exist, cannot continue"
+- exit 1
+- fi
+- # If there is no PIDfile then we can set the pid and break
+- if [ ! -e "${LOCK_PID}" ] ; then
++ mkdir ${LOCK} > /dev/null 2>&1
++ MSL=$?
++ if [ "${MSL}" = "0" ]; then
+ # Lock aquired (setting the pid)
+ echo "$$" > ${LOCK_PID}
+ return;
+@@ -94,6 +85,7 @@
+ if [ "$i" = "${MAX_ITERATION}" ]; then
+ # Unlocking and executing
+ unlock;
++ mkdir ${LOCK} > /dev/null 2>&1
+ echo "$$" > ${LOCK_PID}
+ return;
+ fi
+@@ -102,15 +94,12 @@
+
+
+ # Unlock function
+-# Just remove the lock file if it is there, keep the lock directory
+-# for later. We don't remove the directory (rm -rf is dangerous in a shell script)
+ unlock()
+ {
+- [ ! -e "${LOCK}" ] && return 0
+- [ ! -d "${LOCK}" ] && return 0
+- [ -e "${LOCK_PID}" ] && rm -f ${LOCK_PID}
++ rm -rf ${LOCK}
+ }
+
++
+ # Help message
+ help()
+ {
+@@ -198,14 +187,14 @@
echo "${i} is running..."
fi
done
@@ -9,31 +98,357 @@
}
testconfig()
-@@ -331,6 +331,7 @@
- ;;
- status)
- status
-+ exit $?
- ;;
- help)
- help
+ {
+ # We first loop to check the config.
+ for i in ${SDAEMONS}; do
+- ${DIRECTORY}/bin/${i} -t ${DEBUG_CLI};
++ ${DIR}/bin/${i} -t ${DEBUG_CLI};
+ if [ $? != 0 ]; then
+ echo "${i}: Configuration error. Exiting"
+ unlock;
+@@ -220,7 +209,7 @@
+ SDAEMONS="${DB_DAEMON} ${CSYSLOG_DAEMON} ${AGENTLESS_DAEMON} ossec-maild ossec-execd ossec-analysisd ossec-logcollector ossec-remoted ossec-syscheckd ossec-monitord"
+
+ echo "Starting $NAME $VERSION (by $AUTHOR)..."
+- echo | ${DIRECTORY}/bin/ossec-logtest > /dev/null 2>&1;
++ echo | ${DIR}/bin/ossec-logtest > /dev/null 2>&1;
+ if [ ! $? = 0 ]; then
+ echo "OSSEC analysisd: Testing rules failed. Configuration error. Exiting."
+ exit 1;
+@@ -233,7 +222,7 @@
+ for i in ${SDAEMONS}; do
+ pstatus ${i};
+ if [ $? = 0 ]; then
+- ${DIRECTORY}/bin/${i} ${DEBUG_CLI};
++ ${DIR}/bin/${i} ${DEBUG_CLI};
+ if [ $? != 0 ]; then
+ unlock;
+ exit 1;
+@@ -263,13 +252,13 @@
+ return 0;
+ fi
+
+- ls ${LOCK}/${pfile}*.pid > /dev/null 2>&1
++ ls ${DIR}/var/run/${pfile}*.pid > /dev/null 2>&1
+ if [ $? = 0 ]; then
+- for j in `cat ${LOCK}/${pfile}*.pid 2>/dev/null`; do
++ for j in `cat ${DIR}/var/run/${pfile}*.pid 2>/dev/null`; do
+ ps -p $j |grep ossec >/dev/null 2>&1
+ if [ ! $? = 0 ]; then
+ echo "${pfile}: Process $j not used by ossec, removing .."
+- rm -f ${LOCK}/${pfile}-$j.pid
++ rm -f ${DIR}/var/run/${pfile}-$j.pid
+ continue;
+ fi
+
+@@ -294,12 +283,12 @@
+ if [ $? = 1 ]; then
+ echo "Killing ${i} .. ";
+
+- kill `cat ${LOCK}/${i}*.pid`;
++ kill `cat ${DIR}/var/run/${i}*.pid`;
+ else
+ echo "${i} not running ..";
+ fi
+
+- rm -f ${LOCK}/${i}*.pid
++ rm -f ${DIR}/var/run/${i}*.pid
+
+ done
+
--- a/src/init/ossec-local.sh
+++ b/src/init/ossec-local.sh
-@@ -342,6 +342,7 @@
- ;;
- status)
- status
-+ exit $?
- ;;
- help)
- help
+@@ -5,13 +5,11 @@
+
+
+ # Getting where we are installed
+-[ -e /etc/ossec-init.conf ] && . /etc/ossec-init.conf # Source the configuration file for DIRECTORY
+-if [ -z "$DIRECTORY" ]; then
+- echo "ERROR: Cannot determine the value of the OSSEC directory"
+- [ ! -e "/etc/ossec-init.conf" ] && echo "ERROR: /etc/ossec-init.conf does not exist"
+- exit 1
+-fi
+-PLIST="${DIRECTORY}/bin/.process_list"
++LOCAL=`dirname $0`;
++cd ${LOCAL}
++PWD=`pwd`
++DIR=`dirname $PWD`;
++PLIST=${DIR}/bin/.process_list;
+
+
+ ### Do not modify bellow here ###
+@@ -30,8 +28,8 @@
+
+
+ ## Locking for the start/stop
+-LOCK="${DIRECTORY}/var/run/ossec-hids/"
+-LOCK_PID="${LOCK}/start-script-lock.pid"
++LOCK="${DIR}/var/start-script-lock"
++LOCK_PID="${LOCK}/pid"
+
+
+ # This number should be more than enough (even if it is
+@@ -45,11 +43,11 @@
+ checkpid()
+ {
+ for i in ${DAEMONS}; do
+- for j in `cat ${LOCK}/${i}*.pid 2>/dev/null`; do
++ for j in `cat ${DIR}/var/run/${i}*.pid 2>/dev/null`; do
+ ps -p $j |grep ossec >/dev/null 2>&1
+ if [ ! $? = 0 ]; then
+- echo "Deleting PID file '${LOCK}/${i}-${j}.pid' not used..."
+- rm ${LOCK}/${i}-${j}.pid
++ echo "Deleting PID file '${DIR}/var/run/${i}-${j}.pid' not used..."
++ rm ${DIR}/var/run/${i}-${j}.pid
+ fi
+ done
+ done
+@@ -64,14 +62,9 @@
+
+ # Providing a lock.
+ while [ 1 ]; do
+- [ ! -e "${LOCK}" ] && mkdir -p ${LOCK} > /dev/null 2>&1
+- # Ensure we can make the LOCK properly first
+- if [ ! -d "${LOCK}" ] ; then
+- echo "ERROR: The configured lock directory ${LOCK} is not a directory or it does not exist, cannot continue"
+- exit 1
+- fi
+- # If there is no PIDfile then we can set the pid and break
+- if [ ! -e "${LOCK_PID}" ] ; then
++ mkdir ${LOCK} > /dev/null 2>&1
++ MSL=$?
++ if [ "${MSL}" = "0" ]; then
+ # Lock aquired (setting the pid)
+ echo "$$" > ${LOCK_PID}
+ return;
+@@ -92,6 +85,7 @@
+ if [ "$i" = "${MAX_ITERATION}" ]; then
+ # Unlocking and executing
+ unlock;
++ mkdir ${LOCK} > /dev/null 2>&1
+ echo "$$" > ${LOCK_PID}
+ return;
+ fi
+@@ -100,13 +94,9 @@
+
+
+ # Unlock function
+-# Just remove the lock file if it is there, keep the lock directory
+-# for later. We don't remove the directory (rm -rf is dangerous in a shell script)
+ unlock()
+ {
+- [ ! -e "${LOCK}" ] && return 0
+- [ ! -d "${LOCK}" ] && return 0
+- [ -e "${LOCK_PID}" ] && rm -f ${LOCK_PID}
++ rm -rf ${LOCK}
+ }
+
+
+@@ -197,14 +187,14 @@
+ echo "${i} is running..."
+ fi
+ done
+- exit $RETVAL
++ return $RETVAL
+ }
+
+ testconfig()
+ {
+ # We first loop to check the config.
+ for i in ${SDAEMONS}; do
+- ${DIRECTORY}/bin/${i} -t ${DEBUG_CLI};
++ ${DIR}/bin/${i} -t ${DEBUG_CLI};
+ if [ $? != 0 ]; then
+ echo "${i}: Configuration error. Exiting"
+ unlock;
+@@ -220,7 +210,7 @@
+ SDAEMONS="${DB_DAEMON} ${CSYSLOG_DAEMON} ${AGENTLESS_DAEMON} ossec-maild ossec-execd ossec-analysisd ossec-logcollector ossec-syscheckd ossec-monitord"
+
+ echo "Starting $NAME $VERSION (by $AUTHOR)..."
+- echo | ${DIRECTORY}/bin/ossec-logtest > /dev/null 2>&1;
++ echo | ${DIR}/bin/ossec-logtest > /dev/null 2>&1;
+ if [ ! $? = 0 ]; then
+ echo "ossec-analysisd: Configuration error. Exiting."
+ exit 1;
+@@ -234,7 +224,7 @@
+ for i in ${SDAEMONS}; do
+ pstatus ${i};
+ if [ $? = 0 ]; then
+- ${DIRECTORY}/bin/${i} ${DEBUG_CLI};
++ ${DIR}/bin/${i} ${DEBUG_CLI};
+ if [ $? != 0 ]; then
+ unlock;
+ exit 1;
+@@ -272,13 +262,13 @@
+ return 0;
+ fi
+
+- ls ${LOCK}/${pfile}*.pid > /dev/null 2>&1
++ ls ${DIR}/var/run/${pfile}*.pid > /dev/null 2>&1
+ if [ $? = 0 ]; then
+- for j in `cat ${LOCK}/${pfile}*.pid 2>/dev/null`; do
++ for j in `cat ${DIR}/var/run/${pfile}*.pid 2>/dev/null`; do
+ ps -p $j |grep ossec >/dev/null 2>&1
+ if [ ! $? = 0 ]; then
+ echo "${pfile}: Process $j not used by ossec, removing .."
+- rm -f ${LOCK}/${pfile}-$j.pid
++ rm -f ${DIR}/var/run/${pfile}-$j.pid
+ continue;
+ fi
+
+@@ -303,12 +293,12 @@
+ if [ $? = 1 ]; then
+ echo "Killing ${i} .. ";
+
+- kill `cat ${LOCK}/${i}*.pid`;
++ kill `cat ${DIR}/var/run/${i}*.pid`;
+ else
+ echo "${i} not running ..";
+ fi
+
+- rm -f ${LOCK}/${i}*.pid
++ rm -f ${DIR}/var/run/${i}*.pid
+
+ done
+
--- a/src/init/ossec-client.sh
+++ b/src/init/ossec-client.sh
-@@ -247,6 +247,7 @@
- ;;
- status)
- status
-+ exit $?
- ;;
- help)
- help
+@@ -4,14 +4,10 @@
+ # Author: Daniel B. Cid <daniel.cid at gmail.com>
+
+
+-[ -e /etc/ossec-init.conf ] && . /etc/ossec-init.conf # Source the configuration file for DIRECTORY
+-if [ -z "$DIRECTORY" ]; then
+- echo "ERROR: Cannot determine the value of the OSSEC directory"
+- [ ! -e "/etc/ossec-init.conf" ] && echo "ERROR: /etc/ossec-init.conf does not exist"
+- exit 1
+-fi
+ LOCAL=`dirname $0`;
+ cd ${LOCAL}
++PWD=`pwd`
++DIR=`dirname $PWD`;
+
+ ### Do not modify bellow here ###
+ NAME="OSSEC HIDS"
+@@ -21,8 +17,8 @@
+
+
+ ## Locking for the start/stop
+-LOCK="${DIRECTORY}/var/run/ossec-hids/"
+-LOCK_PID="${LOCK}/start-script-lock.pid"
++LOCK="${DIR}/var/start-script-lock"
++LOCK_PID="${LOCK}/pid"
+
+
+ # This number should be more than enough (even if it is
+@@ -36,11 +32,11 @@
+ checkpid()
+ {
+ for i in ${DAEMONS}; do
+- for j in `cat ${LOCK}/${i}*.pid 2>/dev/null`; do
++ for j in `cat ${DIR}/var/run/${i}*.pid 2>/dev/null`; do
+ ps -p $j |grep ossec >/dev/null 2>&1
+ if [ ! $? = 0 ]; then
+- echo "Deleting PID file '${LOCK}/${i}-${j}.pid' not used..."
+- rm ${LOCK}/${i}-${j}.pid
++ echo "Deleting PID file '${DIR}/var/run/${i}-${j}.pid' not used..."
++ rm ${DIR}/var/run/${i}-${j}.pid
+ fi
+ done
+ done
+@@ -55,14 +51,9 @@
+
+ # Providing a lock.
+ while [ 1 ]; do
+- [ ! -e "${LOCK}" ] && mkdir -p ${LOCK} > /dev/null 2>&1
+- # Ensure we can make the LOCK properly first
+- if [ ! -d "${LOCK}" ] ; then
+- echo "ERROR: The configured lock directory ${LOCK} is not a directory or it does not exist, cannot continue"
+- exit 1
+- fi
+- # If there is no PIDfile then we can set the pid and break
+- if [ ! -e "${LOCK_PID}" ] ; then
++ mkdir ${LOCK} > /dev/null 2>&1
++ MSL=$?
++ if [ "${MSL}" = "0" ]; then
+ # Lock aquired (setting the pid)
+ echo "$$" > ${LOCK_PID}
+ return;
+@@ -83,23 +74,21 @@
+ if [ "$i" = "${MAX_ITERATION}" ]; then
+ # Unlocking and executing
+ unlock;
++ mkdir ${LOCK} > /dev/null 2>&1
+ echo "$$" > ${LOCK_PID}
+ return;
+ fi
+ done
+ }
+
++
+ # Unlock function
+-# Just remove the lock file if it is there, keep the lock directory
+-# for later. We don't remove the directory (rm -rf is dangerous in a shell script)
+ unlock()
+ {
+- [ ! -e "${LOCK}" ] && return 0
+- [ ! -d "${LOCK}" ] && return 0
+- [ -e "${LOCK_PID}" ] && rm -f ${LOCK_PID}
++ rm -rf ${LOCK}
+ }
+
+-
++
+ # Help message
+ help()
+ {
+@@ -126,7 +115,7 @@
+ {
+ # We first loop to check the config.
+ for i in ${SDAEMONS}; do
+- ${DIRECTORY}/bin/${i} -t;
++ ${DIR}/bin/${i} -t;
+ if [ $? != 0 ]; then
+ echo "${i}: Configuration error. Exiting"
+ unlock;
+@@ -149,7 +138,7 @@
+ for i in ${SDAEMONS}; do
+ pstatus ${i};
+ if [ $? = 0 ]; then
+- ${DIRECTORY}/bin/${i};
++ ${DIR}/bin/${i};
+ if [ $? != 0 ]; then
+ unlock;
+ exit 1;
+@@ -179,13 +168,13 @@
+ return 0;
+ fi
+
+- ls ${LOCK}/${pfile}*.pid > /dev/null 2>&1
++ ls ${DIR}/var/run/${pfile}*.pid > /dev/null 2>&1
+ if [ $? = 0 ]; then
+- for j in `cat ${LOCK}/${pfile}*.pid 2>/dev/null`; do
++ for j in `cat ${DIR}/var/run/${pfile}*.pid 2>/dev/null`; do
+ ps -p $j |grep ossec >/dev/null 2>&1
+ if [ ! $? = 0 ]; then
+ echo "${pfile}: Process $j not used by ossec, removing .."
+- rm -f ${LOCK}/${pfile}-$j.pid
++ rm -f ${DIR}/var/run/${pfile}-$j.pid
+ continue;
+ fi
+
+@@ -210,12 +199,12 @@
+ if [ $? = 1 ]; then
+ echo "Killing ${i} .. ";
+
+- kill `cat ${LOCK}/${i}*.pid`;
++ kill `cat ${DIR}/var/run/${i}*.pid`;
+ else
+ echo "${i} not running ..";
+ fi
+
+- rm -f ${LOCK}/${i}*.pid
++ rm -f ${DIR}/var/run/${i}*.pid
+
+ done
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ossec/pkg-ossec.git
More information about the Pkg-ossec-devel
mailing list