migrate_roundcube.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # info: Disconnect Roundcube from APT and solving issues with Roundcube accidental updates from ATP
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Includes
  7. source $HESTIA/func/main.sh
  8. # get current Roundcube version
  9. source $HESTIA/install/upgrade/upgrade.conf
  10. source $HESTIA/conf/hestia.conf
  11. #----------------------------------------------------------#
  12. # Verifications #
  13. #----------------------------------------------------------#
  14. if [ ! -d "/usr/share/roundcube/" ]; then
  15. echo "ERROR: Roundcube is not managed by apt."
  16. exit 2;
  17. fi
  18. #----------------------------------------------------------#
  19. # Action #
  20. #----------------------------------------------------------#
  21. echo "To remove Roundcube you will need use the root password. Password can be found in /usr/local/hestia/conf/mysql.conf"
  22. read -p 'Would you like to continue? [y/n]' -n 1 -r
  23. echo # (optional) move to a new line
  24. if [[ $REPLY =~ ^[Yy]$ ]]
  25. then
  26. version=$(cat /usr/share/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
  27. # Backup database
  28. echo "#version $version" >> ~/roundcube.sql
  29. echo "SET FOREIGN_KEY_CHECKS = 0;" >> ~/roundcube.sql
  30. mysqldump --add-drop-table roundcube >> ~/roundcube.sql
  31. echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/roundcube.sql
  32. echo '[ * ] Remove Roundcube via ATP'
  33. apt-get autoremove roundcube-core roundcube-mysql roundcube-plugins
  34. echo '[ * ] Delete possible trail'
  35. # make sure everything is deleted
  36. rm -f -r /usr/share/roundcube
  37. rm -f -r /etc/roundcube
  38. rm -f -r /var/lib/roundcube/
  39. # Install Roundcube
  40. $HESTIA/bin/v-add-sys-roundcube
  41. # restore backup
  42. echo "SET FOREIGN_KEY_CHECKS = 0;" > ~/drop_all_tables.sql
  43. ( mysqldump --add-drop-table --no-data -u root roundcube | grep 'DROP TABLE' ) >> ./drop_all_tables.sql
  44. echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/drop_all_tables.sql
  45. mysql -u root roundcube < ./drop_all_tables.sql
  46. mysql roundcube < ~/roundcube.sql
  47. /var/lib/roundcube/bin/update.sh --version "$version"
  48. fi