migrate_roundcube.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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]$ ]]; then
  25. version=$(cat /usr/share/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1)
  26. # Backup database
  27. echo "#version $version" >> ~/roundcube.sql
  28. echo "SET FOREIGN_KEY_CHECKS = 0;" >> ~/roundcube.sql
  29. mysqldump --add-drop-table roundcube >> ~/roundcube.sql
  30. echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/roundcube.sql
  31. echo '[ * ] Remove Roundcube via ATP'
  32. apt-get autoremove roundcube-core roundcube-mysql roundcube-plugins
  33. echo '[ * ] Delete possible trail'
  34. # make sure everything is deleted
  35. rm -f -r /usr/share/roundcube
  36. rm -f -r /etc/roundcube
  37. rm -f -r /var/lib/roundcube/
  38. # Install Roundcube
  39. $BIN/v-add-sys-roundcube
  40. # restore backup
  41. echo "SET FOREIGN_KEY_CHECKS = 0;" > ~/drop_all_tables.sql
  42. (mysqldump --add-drop-table --no-data -u root roundcube | grep 'DROP TABLE') >> ./drop_all_tables.sql
  43. echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/drop_all_tables.sql
  44. mysql -u root roundcube < ./drop_all_tables.sql
  45. mysql roundcube < ~/roundcube.sql
  46. /var/lib/roundcube/bin/update.sh --version "$version"
  47. fi