diff --git a/src/init/ossec-client.sh b/src/init/ossec-client.sh index 723380e..0f62f22 100755 --- a/src/init/ossec-client.sh +++ b/src/init/ossec-client.sh @@ -7,7 +7,7 @@ LOCAL=`dirname $0`; cd ${LOCAL} PWD=`pwd` DIR=`dirname $PWD`; - +RUNTIME_DIR="/var/lib/ossec" ### Do not modify bellow here ### NAME="OSSEC HIDS" @@ -18,7 +18,7 @@ DAEMONS="ossec-logcollector ossec-syscheckd ossec-agentd ossec-execd" [ -f /etc/ossec-init.conf ] && . /etc/ossec-init.conf ## Locking for the start/stop -LOCK="${DIR}/var/start-script-lock" +LOCK="${RUNTIME_DIR}/var/start-script-lock" LOCK_PID="${LOCK}/pid" # This number should be more than enough (even if it is @@ -29,11 +29,11 @@ MAX_ITERATION="10" checkpid() { for i in ${DAEMONS}; do - for j in `cat ${DIR}/var/run/${i}*.pid 2>/dev/null`; do + for j in `cat ${RUNTIME_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 '${DIR}/var/run/${i}-${j}.pid' not used..." - rm ${DIR}/var/run/${i}-${j}.pid + echo "Deleting PID file '${RUNTIME_DIR}/var/run/${i}-${j}.pid' not used..." + rm ${RUNTIME_DIR}/var/run/${i}-${j}.pid fi done done @@ -157,13 +157,13 @@ pstatus() return 0; fi - ls ${DIR}/var/run/${pfile}*.pid > /dev/null 2>&1 + ls ${RUNTIME_DIR}/var/run/${pfile}*.pid > /dev/null 2>&1 if [ $? = 0 ]; then - for j in `cat ${DIR}/var/run/${pfile}*.pid 2>/dev/null`; do + for j in `cat ${RUNTIME_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 ${DIR}/var/run/${pfile}-$j.pid + rm -f ${RUNTIME_DIR}/var/run/${pfile}-$j.pid continue; fi @@ -186,12 +186,12 @@ stopa() if [ $? = 1 ]; then echo "Killing ${i} .. "; - kill `cat ${DIR}/var/run/${i}*.pid`; + kill `cat ${RUNTIME_DIR}/var/run/${i}*.pid`; else echo "${i} not running .."; fi - rm -f ${DIR}/var/run/${i}*.pid + rm -f ${RUNTIME_DIR}/var/run/${i}*.pid done unlock; diff --git a/src/init/ossec-server.sh b/src/init/ossec-server.sh index 44214b4..43c4b13 100755 --- a/src/init/ossec-server.sh +++ b/src/init/ossec-server.sh @@ -8,6 +8,7 @@ LOCAL=`dirname $0`; cd ${LOCAL} PWD=`pwd` DIR=`dirname $PWD`; +RUNTIME_DIR="/var/lib/ossec" PLIST=${DIR}/bin/.process_list; ### Do not modify bellow here ### @@ -27,7 +28,8 @@ AUTHOR="Trend Micro Inc." DAEMONS="ossec-monitord ossec-logcollector ossec-remoted ossec-syscheckd ossec-analysisd ossec-maild ossec-execd ${DB_DAEMON} ${CSYSLOG_DAEMON} ${AGENTLESS_DAEMON}" ## Locking for the start/stop -LOCK="${DIR}/var/start-script-lock" +#LOCK="${DIR}/var/start-script-lock" +LOCK="${RUNTIME_DIR}/var/start-script-lock" LOCK_PID="${LOCK}/pid" # This number should be more than enough (even if it is @@ -38,11 +40,11 @@ MAX_ITERATION="10" checkpid() { for i in ${DAEMONS}; do - for j in `cat ${DIR}/var/run/${i}*.pid 2>/dev/null`; do + for j in `cat ${RUNTIME_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 '${DIR}/var/run/${i}-${j}.pid' not used..." - rm ${DIR}/var/run/${i}-${j}.pid + echo "Deleting PID file '${RUNTIME_DIR}/var/run/${i}-${j}.pid' not used..." + rm ${RUNTIME_DIR}/var/run/${i}-${j}.pid fi done done @@ -228,13 +230,13 @@ pstatus() return 0; fi - ls ${DIR}/var/run/${pfile}*.pid > /dev/null 2>&1 + ls ${RUNTIME_DIR}/var/run/${pfile}*.pid > /dev/null 2>&1 if [ $? = 0 ]; then - for j in `cat ${DIR}/var/run/${pfile}*.pid 2>/dev/null`; do + for j in `cat ${RUNTIME_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 ${DIR}/var/run/${pfile}-$j.pid + rm -f ${RUNTIME_DIR}/var/run/${pfile}-$j.pid continue; fi @@ -257,11 +259,11 @@ stopa() if [ $? = 1 ]; then echo "Killing ${i} .. "; - kill `cat ${DIR}/var/run/${i}*.pid`; + kill `cat ${RUNTIME_DIR}/var/run/${i}*.pid`; else echo "${i} not running .."; fi - rm -f ${DIR}/var/run/${i}*.pid + rm -f ${RUNTIME_DIR}/var/run/${i}*.pid done unlock;