2 # Shell script update functions for the OSSEC HIDS
3 # Author: Daniel B. Cid <daniel.cid@gmail.com>
4 # Last modification: May 24, 2006
16 ls -la ${OSSEC_INIT} > /dev/null 2>&1
19 if [ "X$DIRECTORY" = "X" ]; then
23 ls -la $DIRECTORY > /dev/null 2>&1
42 if [ "X$DIRECTORY" = "X" ]; then
43 # Invalid ossec init file. Unable to update
48 # Checking if the directory is valid.
49 echo $DIRECTORY | grep -E "^/[a-zA-Z0-9/-]{3,128}$" > /dev/null 2>&1
65 cat $DIRECTORY/etc/ossec.conf | grep "<client>" > /dev/null 2>&1
71 cat $DIRECTORY/etc/ossec.conf | grep "<remote>" > /dev/null 2>&1
100 $DIRECTORY/bin/ossec-control start
111 $DIRECTORY/bin/ossec-control stop
113 # We also need to remove all syscheck queue file (format changed)
114 if [ "X$VERSION" = "X0.9-3" ]; then
115 rm -f $DIRECTORY/queue/syscheck/* > /dev/null 2>&1
116 rm -f $DIRECTORY/queue/agent-info/* > /dev/null 2>&1
118 rm -f $DIRECTORY/queue/syscheck/.* > /dev/null 2>&1
129 OSSEC_CONF_FILE="$DIRECTORY/etc/ossec.conf"
131 # Backing up the old config
132 cp -pr ${OSSEC_CONF_FILE} "${OSSEC_CONF_FILE}.$$.bak"
134 cat ${OSSEC_CONF_FILE}|grep -v "<rules>" |grep -v "</rules>" |grep -v "<include>" > "${OSSEC_CONF_FILE}.$$.tmp"
136 cat "${OSSEC_CONF_FILE}.$$.tmp" > ${OSSEC_CONF_FILE}
137 rm "${OSSEC_CONF_FILE}.$$.tmp"
138 echo "" >> ${OSSEC_CONF_FILE}
139 echo "<ossec_config> <!-- rules global entry -->" >> ${OSSEC_CONF_FILE}
140 cat ${RULES_TEMPLATE} >> ${OSSEC_CONF_FILE}
141 echo "</ossec_config> <!-- rules global entry -->" >> ${OSSEC_CONF_FILE}