-
Notifications
You must be signed in to change notification settings - Fork 90
/
postrm
65 lines (47 loc) · 1.36 KB
/
postrm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# postrm script for wazuh-agent
# Wazuh, Inc 2015
set -e
DIR="/var/ossec"
WAZUH_TMP_DIR="${DIR}/packages_files/agent_config_files"
case "$1" in
remove|failed-upgrade|abort-install|abort-upgrade|disappear)
if [ -d ${WAZUH_TMP_DIR} ]; then
rm -rf ${WAZUH_TMP_DIR}
fi
# Back up the old configuration files as .save
if [ ! -d ${DIR}/etc ]; then
mkdir -p ${DIR}/etc
fi
# If the directory is not empty, copy the files into ${DIR}/etc
if ls -A ${DIR}/tmp/conffiles > /dev/null 2>&1 ; then
mv ${DIR}/tmp/conffiles/* ${DIR}/etc
fi
rm -rf ${DIR}/tmp
if [ "$1" = "remove" ]; then
rm -rf ${DIR}/ruleset
rm -rf ${DIR}/var
rm -rf ${DIR}/logs
fi
# Delete old .save
find ${DIR}/etc/ -type f -name "*save" -exec rm -f {} \;
# Rename the files
find ${DIR}/etc/ -type f -exec mv {} {}.save \;
;;
purge)
if getent passwd wazuh >/dev/null 2>&1; then
deluser wazuh > /dev/null 2>&1
fi
if getent group wazuh >/dev/null 2>&1; then
delgroup wazuh > /dev/null 2>&1
fi
rm -rf ${DIR}/*
;;
upgrade)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0