pma.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #SOME WORK with DATABASE (table / user)
  43. PMADB=phpmyadmin
  44. PMAUSER=pma
  45. #DROP USER and TABLE
  46. # mysql -uroot <<MYSQL_PMA1
  47. # DROP USER '$PMAUSER'@'localhost';
  48. # DROP DATABASE $PMADB;
  49. # FLUSH PRIVILEGES;
  50. # MYSQL_PMA1
  51. #CREATE PMA USER
  52. mysql -uroot <<MYSQL_PMA2
  53. CREATE USER '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
  54. CREATE DATABASE $PMADB;
  55. MYSQL_PMA2
  56. #GRANT PMA USE SOME RIGHTS
  57. mysql -uroot <<MYSQL_PMA3
  58. USE $PMADB;
  59. GRANT USAGE ON $PMADB.* TO '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
  60. GRANT ALL PRIVILEGES ON $PMADB.* TO '$PMAUSER'@'localhost';
  61. FLUSH PRIVILEGES;
  62. MYSQL_PMA3
  63. #MYSQL DB and TABLES ADDITION
  64. mysql -uroot < $HESTIA_INSTALL_DIR/phpmyadmin/create_tables.sql