v-list-sys-php-config 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # info: list php config parameters
  3. # options: [FORMAT]
  4. # labels: panel
  5. #
  6. # example: v-list-sys-php-config
  7. #
  8. # The function for obtaining the list of php config parameters.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. format=${1-shell}
  14. # Includes
  15. source $HESTIA/func/main.sh
  16. source $HESTIA/conf/hestia.conf
  17. # JSON list function
  18. json_list() {
  19. parse_object_kv_list $(echo "$config"|egrep "$keys"|\
  20. sed -e "s/[ ]*=/=/" -e "s/=[ ]*/=\'/" -e "s/$/'/")
  21. echo '{
  22. "CONFIG": {
  23. "memory_limit": "'$memory_limit'",
  24. "max_execution_time": "'$max_execution_time'",
  25. "max_input_time": "'$max_input_time'",
  26. "upload_max_filesize": "'$upload_max_filesize'",
  27. "post_max_size": "'$post_max_size'",
  28. "display_errors": "'$display_errors'",
  29. "error_reporting": "'$error_reporting'",
  30. "config_path": "'$config_path'"
  31. }
  32. }'
  33. }
  34. # SHELL list function
  35. shell_list() {
  36. echo "$config" |egrep "$keys" |tr -d '='
  37. echo "config_path $config_path"
  38. }
  39. # PLAIN list function
  40. plain_list() {
  41. echo "$config" |egrep "$keys" |tr -d '='
  42. echo "config_path $config_path"
  43. }
  44. # CSV list function
  45. csv_list() {
  46. echo "$keys" |sed "s/ |/,/g"
  47. echo "$config" |egrep "$keys" |tr -d '=' |awk '{print $2}' |tr '\n' ','
  48. echo
  49. }
  50. #----------------------------------------------------------#
  51. # Action #
  52. #----------------------------------------------------------#
  53. # Defining config path
  54. config_path=$(find /etc/php* -name php.ini)
  55. config_count=$(echo "$config_path" |wc -l)
  56. if [ "$config_count" -gt 1 ]; then
  57. multiphp_versions=$(ls -d /etc/php/*/fpm/pool.d 2>/dev/null |wc -l)
  58. if [ "$WEB_BACKEND" = 'php-fpm' ] || [ "$multiphp_versions" -gt 0 ] ; then
  59. config_path=$(echo "$config_path"| grep fpm)
  60. else
  61. config_path=$(echo "$config_path"| grep apache)
  62. fi
  63. fi
  64. # Defining keys
  65. keys="memory_limit |max_execution_time |max_input_time"
  66. keys="$keys |upload_max_filesize |post_max_size"
  67. keys="$keys |display_errors |error_reporting "
  68. # Reading config
  69. config=$(cat $config_path|grep -v "^;")
  70. # Listing data
  71. case $format in
  72. json) json_list ;;
  73. plain) plain_list ;;
  74. csv) csv_list ;;
  75. shell) shell_list |column -t;;
  76. esac
  77. #----------------------------------------------------------#
  78. # Hestia #
  79. #----------------------------------------------------------#
  80. exit