Skip to content

Commit

Permalink
Prevent installation/update errors when backup directory exists #32
Browse files Browse the repository at this point in the history
  • Loading branch information
BraulioV committed Aug 27, 2018
1 parent 0d0a390 commit 27ee216
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 10 deletions.
5 changes: 5 additions & 0 deletions debs/SPECS/3.5.0/wazuh-agent/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Wazuh, Inc 2016

set -e
WAZUH_TMP_DIR="/tmp/wazuh-agent"

case "$1" in
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
Expand All @@ -20,6 +21,10 @@ case "$1" in
rm -f /etc/ossec-init.conf
fi

if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi

update-rc.d -f wazuh-agent remove

;;
Expand Down
7 changes: 5 additions & 2 deletions debs/SPECS/3.5.0/wazuh-agent/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ DIR="/var/ossec"

# environment configuration
if [ ! -d ${WAZUH_TMP_DIR} ]; then
mkdir ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
else
rm -rf ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
fi

case "$1" in
Expand Down Expand Up @@ -47,7 +50,7 @@ case "$1" in
fi

if [ ! -z "$files" ]; then
mkdir ${WAZUH_TMP_DIR}/group
mkdir -p ${WAZUH_TMP_DIR}/group
cp -rp ${DIR}/etc/shared/* ${WAZUH_TMP_DIR}/group/
fi
;;
Expand Down
6 changes: 6 additions & 0 deletions debs/SPECS/3.5.0/wazuh-api/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

DIR="/var/ossec"
WAZUH_API_DIR="${DIR}/api"
WAZUH_TMP_DIR="/tmp/wazuh-api"

set -e

Expand All @@ -27,6 +28,11 @@ case "$1" in
if [ -L ${WAZUH_API_DIR}/configuration/auth/htpasswd ]; then
rm ${WAZUH_API_DIR}/configuration/auth/htpasswd
fi

if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi

;;
purge)
rm -rf ${WAZUH_API_DIR}/ ${DIR}/~api/
Expand Down
5 changes: 4 additions & 1 deletion debs/SPECS/3.5.0/wazuh-api/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ DIR="/var/ossec"

# environment configuration
if [ ! -d ${WAZUH_TMP_DIR} ]; then
mkdir ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
else
rm -rf ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
fi

case "$1" in
Expand Down
5 changes: 5 additions & 0 deletions debs/SPECS/3.5.0/wazuh-manager/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Wazuh, Inc 2016
set -e
DIR="/var/ossec"
WAZUH_TMP_DIR="/tmp/wazuh-manager"

case "$1" in
purge|remove|failed-upgrade|abort-install|abort-upgrade|disappear)
Expand Down Expand Up @@ -34,6 +35,10 @@ case "$1" in
rm -f /etc/ossec-init.conf
fi

if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi

update-rc.d -f wazuh-manager remove

;;
Expand Down
7 changes: 5 additions & 2 deletions debs/SPECS/3.5.0/wazuh-manager/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ DIR="/var/ossec"

# environment configuration
if [ ! -d ${WAZUH_TMP_DIR} ]; then
mkdir ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
else
rm -rf ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
fi

case "$1" in
Expand Down Expand Up @@ -63,7 +66,7 @@ case "$1" in
if [ "$1" = "upgrade" ] ; then

if [ ! -d ${DIR}/etc/shared/default ]; then
mkdir ${DIR}/etc/shared/default
mkdir -p ${DIR}/etc/shared/default
chown ossec:ossec ${DIR}/etc/shared/default
chmod -R 770 ${DIR}/etc/shared/default
find ${DIR}/etc/shared -maxdepth 1 -type f \( -name "*.txt" -o -name "merged.mg" \) -exec cp -rp {} ${DIR}etc/shared/default \;
Expand Down
5 changes: 5 additions & 0 deletions debs/SPECS/3.6.0/wazuh-agent/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Wazuh, Inc 2016

set -e
WAZUH_TMP_DIR="/tmp/wazuh-agent"

case "$1" in
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
Expand All @@ -20,6 +21,10 @@ case "$1" in
rm -f /etc/ossec-init.conf
fi

if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi

update-rc.d -f wazuh-agent remove

;;
Expand Down
7 changes: 5 additions & 2 deletions debs/SPECS/3.6.0/wazuh-agent/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ DIR="/var/ossec"

# environment configuration
if [ ! -d ${WAZUH_TMP_DIR} ]; then
mkdir ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
else
rm -rf ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
fi

case "$1" in
Expand Down Expand Up @@ -47,7 +50,7 @@ case "$1" in
fi

if [ ! -z "$files" ]; then
mkdir ${WAZUH_TMP_DIR}/group
mkdir -p ${WAZUH_TMP_DIR}/group
cp -rp ${DIR}/etc/shared/* ${WAZUH_TMP_DIR}/group/
fi
;;
Expand Down
5 changes: 5 additions & 0 deletions debs/SPECS/3.6.0/wazuh-api/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

DIR="/var/ossec"
WAZUH_API_DIR="${DIR}/api"
WAZUH_TMP_DIR="/tmp/wazuh-api"

set -e

Expand All @@ -27,6 +28,10 @@ case "$1" in
if [ -L ${WAZUH_API_DIR}/configuration/auth/htpasswd ]; then
rm ${WAZUH_API_DIR}/configuration/auth/htpasswd
fi

if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi
;;
purge)
rm -rf ${WAZUH_API_DIR}/ ${DIR}/~api/
Expand Down
5 changes: 4 additions & 1 deletion debs/SPECS/3.6.0/wazuh-api/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ DIR="/var/ossec"

# environment configuration
if [ ! -d ${WAZUH_TMP_DIR} ]; then
mkdir ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
else
rm -rf ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
fi

case "$1" in
Expand Down
5 changes: 5 additions & 0 deletions debs/SPECS/3.6.0/wazuh-manager/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Wazuh, Inc 2016
set -e
DIR="/var/ossec"
WAZUH_TMP_DIR="/tmp/wazuh-manager"

case "$1" in
purge|remove|failed-upgrade|abort-install|abort-upgrade|disappear)
Expand Down Expand Up @@ -34,6 +35,10 @@ case "$1" in
rm -f /etc/ossec-init.conf
fi

if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi

update-rc.d -f wazuh-manager remove

;;
Expand Down
7 changes: 5 additions & 2 deletions debs/SPECS/3.6.0/wazuh-manager/debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ DIR="/var/ossec"

# environment configuration
if [ ! -d ${WAZUH_TMP_DIR} ]; then
mkdir ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
else
rm -rf ${WAZUH_TMP_DIR}
mkdir -p ${WAZUH_TMP_DIR}
fi

case "$1" in
Expand Down Expand Up @@ -63,7 +66,7 @@ case "$1" in
if [ "$1" = "upgrade" ] ; then

if [ ! -d ${DIR}/etc/shared/default ]; then
mkdir ${DIR}/etc/shared/default
mkdir -p ${DIR}/etc/shared/default
chown ossec:ossec ${DIR}/etc/shared/default
chmod -R 770 ${DIR}/etc/shared/default
find ${DIR}/etc/shared -maxdepth 1 -type f \( -name "*.txt" -o -name "merged.mg" \) -exec cp -rp {} ${DIR}etc/shared/default \;
Expand Down

0 comments on commit 27ee216

Please sign in to comment.