-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear_all_caches
executable file
·91 lines (75 loc) · 2.54 KB
/
clear_all_caches
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
################################################################################
##
## Clear all cache databases
##
## Copyright (C) 2015-2020 Michael Roland <[email protected]>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
##
################################################################################
SCRIPT_NAME=$(basename $0)
SCRIPT_PATH=$(readlink -f "$(dirname $0)")
. "$SCRIPT_PATH/kolab_config_loader"
usage() {
echo "Usage: ${SCRIPT_NAME} [options]"
echo "Clear all cache databases"
echo ""
echo -e "Options:"
echo -e "\t-h Show this message"
echo ""
echo "Copyright (c) 2015-2020 Michael Roland <[email protected]>"
echo "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/>"
echo ""
echo "This is free software: you can redistribute and/or modify it under the"
echo "terms of the GPLv3+. There is NO WARRANTY; not even the implied warranty"
echo "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
echo ""
}
while getopts ":h?:" opt; do
case "$opt" in
h|\?)
if [ ! -z $OPTARG ] ; then
echo "${SCRIPT_NAME}: invalid option -- $OPTARG" >&2
fi
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
$SCRIPT_PATH/clear_auth_caches
echo "Clearing other caches ..."
# TODO: Switch to using /usr/share/roundcubemail/plugins/libkolab/bin/modcache.sh
echo " Expiring Roundcube caches ..."
${ROUNDCUBE_DB_CMD} <<EOF
delete from cache;
delete from cache_index;
delete from cache_messages;
delete from cache_shared;
delete from cache_thread;
delete from kolab_cache_configuration;
delete from kolab_cache_contact;
delete from kolab_cache_event;
delete from kolab_cache_file;
delete from kolab_cache_freebusy;
delete from kolab_cache_journal;
delete from kolab_cache_note;
delete from kolab_cache_task;
delete from kolab_folders;
EOF
echo " Restaring services ..."
systemctl restart ${SERVICE_WEB}
echo "Done."