pma.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. if [ -f '/usr/bin/mariadb' ]; then
  54. mysql_server="mariadb"
  55. else
  56. mysql_server="mysql"
  57. fi
  58. $mysql_server -uroot << MYSQL_PMA2
  59. CREATE USER '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
  60. CREATE DATABASE $PMADB;
  61. MYSQL_PMA2
  62. #GRANT PMA USE SOME RIGHTS
  63. $mysql_server -uroot << MYSQL_PMA3
  64. USE $PMADB;
  65. GRANT USAGE ON $PMADB.* TO '$PMAUSER'@'localhost' IDENTIFIED BY '$PASS';
  66. GRANT ALL PRIVILEGES ON $PMADB.* TO '$PMAUSER'@'localhost';
  67. FLUSH PRIVILEGES;
  68. MYSQL_PMA3
  69. #MYSQL DB and TABLES ADDITION
  70. $mysql_server -uroot < "$HESTIA_INSTALL_DIR/phpmyadmin/create_tables.sql"