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 "Install Roundcube not done via APT"
  16. exit 2;
  17. fi
  18. echo "For deleting Roundcube you will need confirm the removal with root password. Password can be found in /usr/local/hestia/conf/mysql.conf"
  19. read -p "Please enter Y to continue" -n 1 -r
  20. echo # (optional) move to a new line
  21. if [[ $REPLY =~ ^[Yy]$ ]]
  22. then
  23. version=$(cat /usr/share/roundcube/index.php | grep -o -E '[0-9].[0-9].[0-9]+' | head -1);
  24. # Backup database
  25. echo "#version $version" >> ~/roundcube.sql
  26. echo "SET FOREIGN_KEY_CHECKS = 0;" >> ~/roundcube.sql
  27. mysqldump --add-drop-table roundcube >> ~/roundcube.sql
  28. echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/roundcube.sql
  29. echo '[ * ] Remove Roundcube via ATP'
  30. apt-get autoremove roundcube-core roundcube-mysql roundcube-plugins
  31. echo '[ * ] Delete possible trail'
  32. # make sure everything is deleted
  33. rm -f -r /usr/share/roundcube
  34. rm -f -r /etc/roundcube
  35. rm -f -r /var/lib/roundcube/
  36. # Install Roundcube
  37. $HESTIA/bin/v-add-sys-roundcube
  38. # restore backup
  39. echo "SET FOREIGN_KEY_CHECKS = 0;" > ~/drop_all_tables.sql
  40. ( mysqldump --add-drop-table --no-data -u root roundcube | grep 'DROP TABLE' ) >> ./drop_all_tables.sql
  41. echo "SET FOREIGN_KEY_CHECKS = 1;" >> ~/drop_all_tables.sql
  42. mysql -u root roundcube < ./drop_all_tables.sql
  43. mysql roundcube < ~/roundcube.sql
  44. /var/lib/roundcube/bin/update.sh --version "$version"
  45. fi