pma.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #
  3. # phpmyadmin-fixer
  4. #
  5. # Fixes for phpmyadmin (configuration storage and some extended features)
  6. #
  7. # Original Version by Pavel Galkin (https://skurudo.ru)
  8. # https://github.com/skurudo/phpmyadmin-fixer
  9. #
  10. # Changed some lines to fit to Hestia Configuration.
  11. #
  12. PASS=$(gen_pass)
  13. #ubuntu phpmyadmin path
  14. pmapath="/etc/phpmyadmin/conf.d/01-localhost.php"
  15. echo "<?php " >> $pmapath
  16. echo "\$cfg['Servers'][\$i]['host'] = 'localhost';" >> $pmapath
  17. echo "\$cfg['Servers'][\$i]['port'] = '3306';" >> $pmapath
  18. echo "\$cfg['Servers'][\$i]['favorite'] = 'pma__favorite';" >> $pmapath
  19. echo "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';" >> $pmapath
  20. echo "\$cfg['Servers'][\$i]['central_columns'] = 'pma__central_columns';" >> $pmapath
  21. echo "\$cfg['Servers'][\$i]['designer_settings'] = 'pma__designer_settings';" >> $pmapath
  22. echo "\$cfg['Servers'][\$i]['export_templates'] = 'pma__export_templates';" >> $pmapath
  23. echo "\$cfg['Servers'][\$i]['savedsearches'] = 'pma__savedsearches';" >> $pmapath
  24. echo "\$cfg['Servers'][\$i]['navigationhiding'] = 'pma__navigationhiding';" >> $pmapath
  25. echo "\$cfg['Servers'][\$i]['users'] = 'pma__users';" >> $pmapath
  26. echo "\$cfg['Servers'][\$i]['usergroups'] = 'pma__usergroups';" >> $pmapath
  27. echo "\$cfg['Servers'][\$i]['pmadb'] = 'phpmyadmin';" >> $pmapath
  28. echo "\$cfg['Servers'][\$i]['controluser'] = 'pma';" >> $pmapath
  29. echo "\$cfg['Servers'][\$i]['controlpass'] = '$PASS';" >> $pmapath
  30. echo "\$cfg['Servers'][\$i]['bookmarktable'] = 'pma__bookmark';" >> $pmapath
  31. echo "\$cfg['Servers'][\$i]['relation'] = 'pma__relation';" >> $pmapath
  32. echo "\$cfg['Servers'][\$i]['userconfig'] = 'pma__userconfig';" >> $pmapath
  33. echo "\$cfg['Servers'][\$i]['table_info'] = 'pma__table_info';" >> $pmapath
  34. echo "\$cfg['Servers'][\$i]['column_info'] = 'pma__column_info';" >> $pmapath
  35. echo "\$cfg['Servers'][\$i]['history'] = 'pma__history';" >> $pmapath
  36. echo "\$cfg['Servers'][\$i]['recent'] = 'pma__recent';" >> $pmapath
  37. echo "\$cfg['Servers'][\$i]['table_uiprefs'] = 'pma__table_uiprefs';" >> $pmapath
  38. echo "\$cfg['Servers'][\$i]['tracking'] = 'pma__tracking';" >> $pmapath
  39. echo "\$cfg['Servers'][\$i]['table_coords'] = 'pma__table_coords';" >> $pmapath
  40. echo "\$cfg['Servers'][\$i]['pdf_pages'] = 'pma__pdf_pages';" >> $pmapath
  41. echo "\$cfg['Servers'][\$i]['designer_coords'] = 'pma__designer_coords';" >> $pmapath
  42. echo "\$cfg['Servers'][\$i]['hide_db'] = 'information_schema';" >> $pmapath
  43. #SOME WORK with DATABASE (table / user)
  44. PMADB=phpmyadmin
  45. PMAUSER=pma
  46. #DROP USER and TABLE
  47. # mysql -uroot <<MYSQL_PMA1
  48. # DROP USER '$PMAUSER'@'localhost';
  49. # DROP DATABASE $PMADB;
  50. # FLUSH PRIVILEGES;
  51. # MYSQL_PMA1
  52. #CREATE PMA USER
  53. mysql -uroot << MYSQL_PMA2
  54. CREATE USER '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
  55. CREATE DATABASE $PMADB;
  56. MYSQL_PMA2
  57. #GRANT PMA USE SOME RIGHTS
  58. mysql -uroot << MYSQL_PMA3
  59. USE $PMADB;
  60. GRANT USAGE ON $PMADB.* TO '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
  61. GRANT ALL PRIVILEGES ON $PMADB.* TO '$PMAUSER'@'localhost';
  62. FLUSH PRIVILEGES;
  63. MYSQL_PMA3
  64. #MYSQL DB and TABLES ADDITION
  65. mysql -uroot < "$HESTIA_INSTALL_DIR/phpmyadmin/create_tables.sql"