2
0

spx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'zlib.output_compression = 1');
  3. spx_status() {
  4. if [[ $S == 1 ]]; then
  5. echo "Output compression is enabled, so you cannot currently debug with SPX."
  6. else
  7. echo "Output compression is disabled, so you can currently debug with SPX."
  8. fi
  9. }
  10. spx_toggle() {
  11. if [[ $S == 1 ]]; then
  12. spx_enable
  13. else
  14. spx_disable
  15. fi
  16. }
  17. spx_enable() {
  18. if [[ $S == 1 ]]; then
  19. bin/root sed -i -e 's/^zlib.output_compression = 1/zlib.output_compression = 0/g' /usr/local/etc/php/php.ini
  20. sleep 1
  21. bin/restart phpfpm
  22. echo "Output compression is now disabled, so you can start debugging with SPX."
  23. else
  24. echo "Output compression is already disabled, so you can start debugging with SPX."
  25. fi
  26. }
  27. spx_disable() {
  28. if [[ $S == 0 ]]; then
  29. bin/root sed -i -e 's/^zlib.output_compression = 0/zlib.output_compression = 1/g' /usr/local/etc/php/php.ini
  30. sleep 1
  31. bin/restart phpfpm
  32. echo "Output compression is now enabled, so you can no longer debug with SPX."
  33. else
  34. echo "Output compression is already enabled, so you can no longer debug with SPX."
  35. fi
  36. }
  37. firstArgLetter="$(echo "$1" | head -c 1)"
  38. if [[ $firstArgLetter == "d" ]]; then
  39. spx_disable
  40. elif [[ $firstArgLetter == "e" ]]; then
  41. spx_enable
  42. elif [[ $firstArgLetter == "t" ]]; then
  43. spx_toggle
  44. elif [[ $firstArgLetter == "s" ]]; then
  45. spx_status
  46. else
  47. printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/spx status\n"
  48. fi