v-list-sys-php-config 2.4 KB

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