forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate_roundcube.sh
More file actions
executable file
·55 lines (47 loc) · 2.13 KB
/
migrate_roundcube.sh
File metadata and controls
executable file
·55 lines (47 loc) · 2.13 KB
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
#!/bin/bash
# info: Disconnect Roundcube from APT and solving issues with Roundcube accidental updates from ATP
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $HESTIA/func/main.sh
# get current Roundcube version
source $HESTIA/install/upgrade/upgrade.conf
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
if [ ! -d "/usr/share/roundcube/" ]; then
echo "ERROR: Roundcube is not managed by apt."
exit 2
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
echo "To remove Roundcube you will need use the root password. Password can be found in /usr/local/hestia/conf/mysql.conf"
read -p 'Would you like to continue? [y/n]' -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
version=$(cat /usr/share/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1)
# Backup database
echo "#version $version" >> ~/roundcube.sql
echo "SET FOREIGN_KEY_CHECKS = 0;" >> ~/roundcube.sql
mysqldump --add-drop-table roundcube >> ~/roundcube.sql
echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/roundcube.sql
echo '[ * ] Remove Roundcube via ATP'
apt-get autoremove roundcube-core roundcube-mysql roundcube-plugins
echo '[ * ] Delete possible trail'
# make sure everything is deleted
rm -f -r /usr/share/roundcube
rm -f -r /etc/roundcube
rm -f -r /var/lib/roundcube/
# Install Roundcube
$BIN/v-add-sys-roundcube
# restore backup
echo "SET FOREIGN_KEY_CHECKS = 0;" > ~/drop_all_tables.sql
(mysqldump --add-drop-table --no-data -u root roundcube | grep 'DROP TABLE') >> ./drop_all_tables.sql
echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/drop_all_tables.sql
mysql -u root roundcube < ./drop_all_tables.sql
mysql roundcube < ~/roundcube.sql
/var/lib/roundcube/bin/update.sh --version "$version"
fi