v-change-sys-db-alias 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # info: change phpmyadmin/phppgadmin alias url
  3. # options: type alias
  4. # example: v-change-sys-db-alias pma phpmyadmin
  5. # Sets phpMyAdmin alias to phpmyadmin
  6. #
  7. # example: v-change-sys-db-alias pga phppgadmin
  8. # Sets phpPgAdmin alias to phppgadmin
  9. #
  10. # This function changes the database editor url in
  11. # apache2 or nginx configuration.
  12. #----------------------------------------------------------#
  13. # Variable&Function #
  14. #----------------------------------------------------------#
  15. # Argument definition
  16. type=$1
  17. alias=$2
  18. # Includes
  19. source $HESTIA/func/main.sh
  20. source $HESTIA/conf/hestia.conf
  21. #----------------------------------------------------------#
  22. # Verifications #
  23. #----------------------------------------------------------#
  24. check_args '2' "$#" 'type alias'
  25. # Perform verification if read-only mode is enabled
  26. check_hestia_demo_mode
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Detect common allowed entries for phpMyAdmin
  31. if [ "$type" = "pma" ] || [ "$type" = "PMA" ] || [ "$type" = "phpmyadmin" ]; then
  32. # Set database editor friendly name
  33. db_editor="phpMyAdmin"
  34. # Set new alias value
  35. $BIN/v-change-sys-config-value 'DB_PMA_ALIAS' "$alias"
  36. # Replace old configuration files and update alias
  37. if [ -e "/etc/apache2/conf.d/phpmyadmin.conf" ]; then
  38. rm -f /etc/apache2/conf.d/phpmyadmin.conf
  39. cp -f $HESTIA_INSTALL_DIR/pma/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
  40. sed -i "s|%pma_alias%|$alias|g" /etc/apache2/conf.d/phpmyadmin.conf
  41. # Restart services
  42. $HESTIA/bin/v-restart-service apache2
  43. fi
  44. if [ -e "/etc/nginx/conf.d/phpmyadmin.inc" ]; then
  45. rm -f /etc/nginx/conf.d/phpmyadmin.inc
  46. cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/phpmyadmin.inc
  47. sed -i "s|%pma_alias%|$alias|g" /etc/nginx/conf.d/phpmyadmin.inc
  48. # Restart services
  49. $HESTIA/bin/v-restart-service nginx
  50. fi
  51. fi
  52. # Detect common allowed entries for phpPgAdmin
  53. if [ "$type" = "pga" ] || [ "$type" = "PGA" ] || [ "$type" = "phppgadmin" ]; then
  54. # Set database editor friendly name
  55. db_editor="phpPgAdmin"
  56. # Set new alias value
  57. $BIN/v-change-sys-config-value 'DB_PGA_ALIAS' "$alias"
  58. # Replace old configuration files and update alias
  59. if [ -e "/etc/apache2/conf.d/phppgadmin.conf" ]; then
  60. rm -f /etc/apache2/conf.d/phppgadmin.conf
  61. cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/phppgadmin.conf
  62. sed -i "s|%pga_alias%|$alias|g" /etc/apache2/conf.d/phppgadmin.conf
  63. # Restart services
  64. $HESTIA/bin/v-restart-service apache2
  65. fi
  66. if [ -e "/etc/nginx/conf.d/phppgadmin.inc" ]; then
  67. rm -f /etc/nginx/conf.d/phppgadmin.inc
  68. cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/phppgadmin.inc
  69. sed -i "s|%pga_alias%|$alias|g" /etc/nginx/conf.d/phppgadmin.inc
  70. # Restart services
  71. $HESTIA/bin/v-restart-service nginx
  72. fi
  73. fi
  74. #----------------------------------------------------------#
  75. # Hestia #
  76. #----------------------------------------------------------#
  77. # Logging
  78. log_history "changed $db_editor alias to $alias"
  79. log_event "$OK" "$ARGUMENTS"
  80. exit