nginx.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package self_check
  2. import (
  3. "github.com/0xJacky/Nginx-UI/internal/helper"
  4. "github.com/0xJacky/Nginx-UI/internal/nginx"
  5. )
  6. // CheckConfigDir checks if the config directory exists
  7. func CheckConfigDir() error {
  8. dir := nginx.GetConfPath()
  9. if dir == "" {
  10. return ErrConfigDirNotExist
  11. }
  12. if !helper.FileExists(dir) {
  13. return ErrConfigDirNotExist
  14. }
  15. return nil
  16. }
  17. // CheckConfigEntryFile checks if the config entry file exists
  18. func CheckConfigEntryFile() error {
  19. dir := nginx.GetConfPath()
  20. if dir == "" {
  21. return ErrConfigEntryFileNotExist
  22. }
  23. if !helper.FileExists(dir) {
  24. return ErrConfigEntryFileNotExist
  25. }
  26. return nil
  27. }
  28. // CheckPIDPath checks if the PID path exists
  29. func CheckPIDPath() error {
  30. path := nginx.GetPIDPath()
  31. if path == "" {
  32. return ErrPIDPathNotExist
  33. }
  34. if !helper.FileExists(path) {
  35. return ErrPIDPathNotExist
  36. }
  37. return nil
  38. }
  39. // CheckSbinPath checks if the sbin path exists
  40. func CheckSbinPath() error {
  41. path := nginx.GetSbinPath()
  42. if path == "" {
  43. return ErrSbinPathNotExist
  44. }
  45. if !helper.FileExists(path) {
  46. return ErrSbinPathNotExist
  47. }
  48. return nil
  49. }
  50. // CheckAccessLogPath checks if the access log path exists
  51. func CheckAccessLogPath() error {
  52. path := nginx.GetAccessLogPath()
  53. if path == "" {
  54. return ErrAccessLogPathNotExist
  55. }
  56. if !helper.FileExists(path) {
  57. return ErrAccessLogPathNotExist
  58. }
  59. return nil
  60. }
  61. // CheckErrorLogPath checks if the error log path exists
  62. func CheckErrorLogPath() error {
  63. path := nginx.GetErrorLogPath()
  64. if path == "" {
  65. return ErrErrorLogPathNotExist
  66. }
  67. if !helper.FileExists(path) {
  68. return ErrErrorLogPathNotExist
  69. }
  70. return nil
  71. }